Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
],
"rector": "./vendor/bin/rector process",
"static": "./vendor/bin/phpstan --memory-limit=-1",
Expand Down
4 changes: 3 additions & 1 deletion src/Panel/Event/EventCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$result = [];

foreach (array_slice($fields, 0, 16, true) as $key => $value) {
$result[mb_strcut($key, 0, 128)] = self::text(

Check warning on line 39 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "MBString": @@ @@ $result = []; foreach (array_slice($fields, 0, 16, true) as $key => $value) { - $result[mb_strcut($key, 0, 128)] = self::text( + $result[substr($key, 0, 128)] = self::text( $policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value), ); }

Check warning on line 39 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": @@ @@ $result = []; foreach (array_slice($fields, 0, 16, true) as $key => $value) { - $result[mb_strcut($key, 0, 128)] = self::text( + $result[mb_strcut($key, 0, 129)] = self::text( $policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value), ); }

Check warning on line 39 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ $result = []; foreach (array_slice($fields, 0, 16, true) as $key => $value) { - $result[mb_strcut($key, 0, 128)] = self::text( + $result[mb_strcut($key, 0, 127)] = self::text( $policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value), ); }

Check warning on line 39 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": @@ @@ $result = []; foreach (array_slice($fields, 0, 16, true) as $key => $value) { - $result[mb_strcut($key, 0, 128)] = self::text( + $result[mb_strcut($key, 0, 129)] = self::text( $policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value), ); }

Check warning on line 39 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "MBString": @@ @@ $result = []; foreach (array_slice($fields, 0, 16, true) as $key => $value) { - $result[mb_strcut($key, 0, 128)] = self::text( + $result[substr($key, 0, 128)] = self::text( $policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value), ); }

Check warning on line 39 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ $result = []; foreach (array_slice($fields, 0, 16, true) as $key => $value) { - $result[mb_strcut($key, 0, 128)] = self::text( + $result[mb_strcut($key, 0, 127)] = self::text( $policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value), ); }
$policy->isSensitiveKey($key) ? '[redacted]' : $policy->redactText($value),
);
}
Expand All @@ -58,11 +58,13 @@
$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)) {
break;

Check warning on line 67 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Break_": @@ @@ foreach ($frames as $frame) { if (count($result) >= min(16, $limit)) { - break; + continue; } $file = $frame['file'] ?? null;

Check warning on line 67 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Break_": @@ @@ foreach ($frames as $frame) { if (count($result) >= min(16, $limit)) { - break; + continue; } $file = $frame['file'] ?? null;
}

$file = $frame['file'] ?? null;
Expand Down Expand Up @@ -92,8 +94,8 @@

$value = $prefix === false ? $value : $prefix;

$value = str_replace("\0", '', $value);

Check warning on line 97 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "UnwrapStrReplace": @@ @@ $value = $prefix === false ? $value : $prefix; - $value = str_replace("\0", '', $value); + $value = $value; return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; }

Check warning on line 97 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "UnwrapStrReplace": @@ @@ $value = $prefix === false ? $value : $prefix; - $value = str_replace("\0", '', $value); + $value = $value; return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; }

return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value;

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "MBString": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? substr($value, 0, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? mb_strcut($value, 0, 2035) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? mb_strcut($value, 1, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) >= 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? mb_strcut($value, -1, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "MBString": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? substr($value, 0, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? mb_strcut($value, 0, 2035) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? mb_strcut($value, 1, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) > 2048 ? mb_strcut($value, -1, 2036) . ' [truncated]' : $value; } }

Check warning on line 99 in src/Panel/Event/EventCapture.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "GreaterThan": @@ @@ $value = str_replace("\0", '', $value); - return strlen($value) > 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; + return strlen($value) >= 2048 ? mb_strcut($value, 0, 2036) . ' [truncated]' : $value; } }
}
}
22 changes: 22 additions & 0 deletions tests/Panel/Event/EventInspectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down
Loading