diff --git a/CHANGELOG.md b/CHANGELOG.md index b69d8b8..b380efb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.1.1 Under development +- fix(event): skip `InstrumentationGuard` trace frames on Windows by joining the skip path with `DIRECTORY_SEPARATOR`. + ## 0.1.0 October 16, 2026 - feat: initial development release. diff --git a/composer.json b/composer.json index fda4104..a67c682 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "mutation-static": [ "Composer\\Config::disableProcessTimeout", "./vendor/bin/phpstan clear-result-cache", - "php -d memory_limit=-1 vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'" + "php -d memory_limit=-1 vendor/bin/infection --initial-tests-php-options='-d memory_limit=-1' --test-framework-extra-args='-d memory_limit=-1' --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'" ], "rector": "./vendor/bin/rector process", "static": "./vendor/bin/phpstan --memory-limit=-1", diff --git a/src/Panel/Event/EventCapture.php b/src/Panel/Event/EventCapture.php index e24d057..6c339d3 100644 --- a/src/Panel/Event/EventCapture.php +++ b/src/Panel/Event/EventCapture.php @@ -58,7 +58,9 @@ public static function trace(array $frames, int $limit, array $skipFiles = []): $result = []; $skipFiles[] = __FILE__; - $skipFiles[] = dirname(__DIR__, 2) . '/Instrumentation/InstrumentationGuard.php'; + $skipFiles[] = dirname(__DIR__, 2) + . DIRECTORY_SEPARATOR . 'Instrumentation' + . DIRECTORY_SEPARATOR . 'InstrumentationGuard.php'; foreach ($frames as $frame) { if (count($result) >= min(16, $limit)) { diff --git a/tests/Panel/Event/EventInspectionTest.php b/tests/Panel/Event/EventInspectionTest.php index 286eb7d..092bfcb 100644 --- a/tests/Panel/Event/EventInspectionTest.php +++ b/tests/Panel/Event/EventInspectionTest.php @@ -5,11 +5,13 @@ namespace PHPForge\Debug\Tests\Panel\Event; use Closure; +use PHPForge\Debug\Instrumentation\InstrumentationGuard; use PHPForge\Debug\Panel\Event\{EventCapture, EventInspection, EventInspectorRenderer, EventRow, EventSequence, EventSnapshot}; use PHPForge\Debug\Storage\HydrationException; use PHPForge\Debug\Tests\Provider\EventInspectionProvider; use PHPUnit\Framework\Attributes\{DataProviderExternal, Group}; use PHPUnit\Framework\TestCase; +use ReflectionClass; use function array_replace; use function strlen; @@ -614,6 +616,26 @@ public function testTraceNeverRetainsArgumentsOrObjects(): void ); } + public function testTraceSkipsInstrumentationGuardFramesWithNativeSeparators(): void + { + $frames = [ + [ + 'file' => (string) (new ReflectionClass(InstrumentationGuard::class))->getFileName(), + 'line' => 36, + ], + [ + 'file' => '/app/event.php', + 'line' => 42, + ], + ]; + + self::assertSame( + ['/app/event.php:42'], + EventCapture::trace($frames, 16), + 'Instrumentation guard frames must be skipped on every platform.', + ); + } + private static function row(float $time): EventRow { return new EventRow($time, 'render', 'ViewEvent', '0', 'View');