Skip to content

Commit 8a252ab

Browse files
authored
Skip loading stubs if excimer is availiable (#1710)
1 parent 6f8cce5 commit 8a252ab

6 files changed

+48
-27
lines changed

stubs/ExcimerLog.stub

+32-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
namespace {
4+
if (extension_loaded('excimer')) {
5+
return;
6+
}
47

58
/**
69
* A collected series of stack traces and some utility methods to aggregate them.
@@ -22,9 +25,9 @@ namespace {
2225
* are available via:
2326
* - ExcimerProfiler::getLog()
2427
* - ExcimerProfiler::flush()
25-
* - The callback to ExcimerProfiler::setFlushCallback()
28+
* - The callback to ExcimerProfiler::setFlushCallback().
2629
*/
27-
private final function __construct()
30+
final private function __construct()
2831
{
2932
}
3033

@@ -38,7 +41,7 @@ namespace {
3841
*
3942
* @return string
4043
*/
41-
function formatCollapsed()
44+
public function formatCollapsed()
4245
{
4346
}
4447

@@ -69,16 +72,16 @@ namespace {
6972
*
7073
* @return array
7174
*/
72-
function aggregateByFunction()
75+
public function aggregateByFunction()
7376
{
7477
}
7578

7679
/**
77-
* Get an array which can be JSON encoded for import into speedscope
80+
* Get an array which can be JSON encoded for import into speedscope.
7881
*
7982
* @return array
8083
*/
81-
function getSpeedscopeData()
84+
public function getSpeedscopeData()
8285
{
8386
}
8487

@@ -87,7 +90,7 @@ namespace {
8790
*
8891
* @return int
8992
*/
90-
function getEventCount()
93+
public function getEventCount()
9194
{
9295
}
9396

@@ -96,8 +99,8 @@ namespace {
9699
*
97100
* @return ExcimerLogEntry
98101
*/
99-
#[\ReturnTypeWillChange]
100-
function current()
102+
#[ReturnTypeWillChange]
103+
public function current()
101104
{
102105
}
103106

@@ -106,8 +109,8 @@ namespace {
106109
*
107110
* @return int
108111
*/
109-
#[\ReturnTypeWillChange]
110-
function key()
112+
#[ReturnTypeWillChange]
113+
public function key()
111114
{
112115
}
113116

@@ -116,8 +119,8 @@ namespace {
116119
*
117120
* @return void
118121
*/
119-
#[\ReturnTypeWillChange]
120-
function next()
122+
#[ReturnTypeWillChange]
123+
public function next()
121124
{
122125
}
123126

@@ -126,8 +129,8 @@ namespace {
126129
*
127130
* @return void
128131
*/
129-
#[\ReturnTypeWillChange]
130-
function rewind()
132+
#[ReturnTypeWillChange]
133+
public function rewind()
131134
{
132135
}
133136

@@ -136,8 +139,8 @@ namespace {
136139
*
137140
* @return bool
138141
*/
139-
#[\ReturnTypeWillChange]
140-
function valid()
142+
#[ReturnTypeWillChange]
143+
public function valid()
141144
{
142145
}
143146

@@ -148,7 +151,7 @@ namespace {
148151
*
149152
* @return int
150153
*/
151-
function count()
154+
public function count()
152155
{
153156
}
154157

@@ -157,33 +160,35 @@ namespace {
157160
* Part of the ArrayAccess interface.
158161
*
159162
* @param int $offset
163+
*
160164
* @return bool
161165
*/
162-
#[\ReturnTypeWillChange]
163-
function offsetExists($offset)
166+
#[ReturnTypeWillChange]
167+
public function offsetExists($offset)
164168
{
165169
}
166170

167171
/**
168172
* Get the ExcimerLogEntry object at the specified array offset.
169173
*
170174
* @param int $offset
175+
*
171176
* @return ExcimerLogEntry
172177
*/
173-
#[\ReturnTypeWillChange]
174-
function offsetGet($offset)
178+
#[ReturnTypeWillChange]
179+
public function offsetGet($offset)
175180
{
176181
}
177182

178183
/**
179184
* This function is included for compliance with the ArrayAccess interface.
180185
* It raises a warning and does nothing.
181186
*
182-
* @param int|null $offset
187+
* @param int|null $offset
183188
* @param ExcimerLogEntry $value
184189
*/
185-
#[\ReturnTypeWillChange]
186-
function offsetSet($offset, $value)
190+
#[ReturnTypeWillChange]
191+
public function offsetSet($offset, $value)
187192
{
188193
}
189194

@@ -193,8 +198,8 @@ namespace {
193198
*
194199
* @param int $offset
195200
*/
196-
#[\ReturnTypeWillChange]
197-
function offsetUnset($offset)
201+
#[ReturnTypeWillChange]
202+
public function offsetUnset($offset)
198203
{
199204
}
200205
}

stubs/ExcimerLogEntry.stub

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
namespace {
4+
if (extension_loaded('excimer')) {
5+
return;
6+
}
47

58
class ExcimerLogEntry
69
{

stubs/ExcimerProfiler.stub

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
namespace {
4+
if (extension_loaded('excimer')) {
5+
return;
6+
}
47

58
/**
69
* A sampling profiler.

stubs/ExcimerTimer.stub

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
namespace {
4+
if (extension_loaded('excimer')) {
5+
return;
6+
}
47

58
/**
69
* Generic timer class. Calls a callback after a specified time has elapsed, or

stubs/autoload.php

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
declare(strict_types=1);
44

5+
if (extension_loaded('excimer')) {
6+
return;
7+
}
8+
59
require_once __DIR__ . '/ExcimerLog.stub';
610
require_once __DIR__ . '/ExcimerLogEntry.stub';
711
require_once __DIR__ . '/ExcimerProfiler.stub';

stubs/globals.stub

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?php
22

33
namespace {
4+
if (extension_loaded('excimer')) {
5+
return;
6+
}
47

58
/** Real (wall-clock) time */
69
define( 'EXCIMER_REAL', 0 );

0 commit comments

Comments
 (0)