Skip to content

Commit

Permalink
Skip loading stubs if excimer is availiable (#1710)
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive authored Mar 5, 2024
1 parent 6f8cce5 commit 8a252ab
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
59 changes: 32 additions & 27 deletions stubs/ExcimerLog.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace {
if (extension_loaded('excimer')) {
return;
}

/**
* A collected series of stack traces and some utility methods to aggregate them.
Expand All @@ -22,9 +25,9 @@ namespace {
* are available via:
* - ExcimerProfiler::getLog()
* - ExcimerProfiler::flush()
* - The callback to ExcimerProfiler::setFlushCallback()
* - The callback to ExcimerProfiler::setFlushCallback().
*/
private final function __construct()
final private function __construct()
{
}

Expand All @@ -38,7 +41,7 @@ namespace {
*
* @return string
*/
function formatCollapsed()
public function formatCollapsed()
{
}

Expand Down Expand Up @@ -69,16 +72,16 @@ namespace {
*
* @return array
*/
function aggregateByFunction()
public function aggregateByFunction()
{
}

/**
* Get an array which can be JSON encoded for import into speedscope
* Get an array which can be JSON encoded for import into speedscope.
*
* @return array
*/
function getSpeedscopeData()
public function getSpeedscopeData()
{
}

Expand All @@ -87,7 +90,7 @@ namespace {
*
* @return int
*/
function getEventCount()
public function getEventCount()
{
}

Expand All @@ -96,8 +99,8 @@ namespace {
*
* @return ExcimerLogEntry
*/
#[\ReturnTypeWillChange]
function current()
#[ReturnTypeWillChange]
public function current()
{
}

Expand All @@ -106,8 +109,8 @@ namespace {
*
* @return int
*/
#[\ReturnTypeWillChange]
function key()
#[ReturnTypeWillChange]
public function key()
{
}

Expand All @@ -116,8 +119,8 @@ namespace {
*
* @return void
*/
#[\ReturnTypeWillChange]
function next()
#[ReturnTypeWillChange]
public function next()
{
}

Expand All @@ -126,8 +129,8 @@ namespace {
*
* @return void
*/
#[\ReturnTypeWillChange]
function rewind()
#[ReturnTypeWillChange]
public function rewind()
{
}

Expand All @@ -136,8 +139,8 @@ namespace {
*
* @return bool
*/
#[\ReturnTypeWillChange]
function valid()
#[ReturnTypeWillChange]
public function valid()
{
}

Expand All @@ -148,7 +151,7 @@ namespace {
*
* @return int
*/
function count()
public function count()
{
}

Expand All @@ -157,33 +160,35 @@ namespace {
* Part of the ArrayAccess interface.
*
* @param int $offset
*
* @return bool
*/
#[\ReturnTypeWillChange]
function offsetExists($offset)
#[ReturnTypeWillChange]
public function offsetExists($offset)
{
}

/**
* Get the ExcimerLogEntry object at the specified array offset.
*
* @param int $offset
*
* @return ExcimerLogEntry
*/
#[\ReturnTypeWillChange]
function offsetGet($offset)
#[ReturnTypeWillChange]
public function offsetGet($offset)
{
}

/**
* This function is included for compliance with the ArrayAccess interface.
* It raises a warning and does nothing.
*
* @param int|null $offset
* @param int|null $offset
* @param ExcimerLogEntry $value
*/
#[\ReturnTypeWillChange]
function offsetSet($offset, $value)
#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
}

Expand All @@ -193,8 +198,8 @@ namespace {
*
* @param int $offset
*/
#[\ReturnTypeWillChange]
function offsetUnset($offset)
#[ReturnTypeWillChange]
public function offsetUnset($offset)
{
}
}
Expand Down
3 changes: 3 additions & 0 deletions stubs/ExcimerLogEntry.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace {
if (extension_loaded('excimer')) {
return;
}

class ExcimerLogEntry
{
Expand Down
3 changes: 3 additions & 0 deletions stubs/ExcimerProfiler.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace {
if (extension_loaded('excimer')) {
return;
}

/**
* A sampling profiler.
Expand Down
3 changes: 3 additions & 0 deletions stubs/ExcimerTimer.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace {
if (extension_loaded('excimer')) {
return;
}

/**
* Generic timer class. Calls a callback after a specified time has elapsed, or
Expand Down
4 changes: 4 additions & 0 deletions stubs/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

declare(strict_types=1);

if (extension_loaded('excimer')) {
return;
}

require_once __DIR__ . '/ExcimerLog.stub';
require_once __DIR__ . '/ExcimerLogEntry.stub';
require_once __DIR__ . '/ExcimerProfiler.stub';
Expand Down
3 changes: 3 additions & 0 deletions stubs/globals.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

namespace {
if (extension_loaded('excimer')) {
return;
}

/** Real (wall-clock) time */
define( 'EXCIMER_REAL', 0 );
Expand Down

0 comments on commit 8a252ab

Please sign in to comment.