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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- feat: add shared framework-neutral normalization and presentation helpers for debug adapters.
- feat: add validated collector contracts, lifecycle coordination, and isolated typed snapshot capture for adapters.
- fix: guard the user-switch panel against concurrent submits so a double-click (or set + reset in the same tick) sends a single identity-switch request instead of racing two session regenerations.
- test: strengthen mutation coverage and clear PHPStan's result cache before static mutation analysis.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"ext-intl": "*",
"ext-mbstring": "*",
"ui-awesome/html": "^0.6",
"ui-awesome/html-core-component": "^0.4",
"ui-awesome/html-helper": "^0.7",
"ui-awesome/html-interop": "^0.4",
"ui-awesome/html-svg": "^0.6"
},
"require-dev": {
Expand Down Expand Up @@ -73,6 +75,7 @@
"mutation": "php -d memory_limit=-1 vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100",
"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'"
],
"rector": "./vendor/bin/rector process",
Expand Down
93 changes: 0 additions & 93 deletions resources/views/history.php

This file was deleted.

89 changes: 0 additions & 89 deletions resources/views/sidebar.php

This file was deleted.

5 changes: 3 additions & 2 deletions src/Helper/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use function get_debug_type;
use function gettype;
use function is_array;
use function is_scalar;
use function range;
use function str_repeat;
use function var_export;
Expand Down Expand Up @@ -79,7 +80,7 @@ private static function dumpArray(array $value, int $depth, int $level): string

foreach (array_keys($value) as $key) {
$output .= "\n{$spaces} ";
$output .= self::dumpInternal($key, $depth, 0);
$output .= self::dumpInternal($key, $depth, $level);
$output .= ' => ';
$output .= self::dumpInternal($value[$key], $depth, $level + 1);
}
Expand Down Expand Up @@ -126,7 +127,7 @@ private static function exportInternal(mixed $value, int $level): string
$output .= "\n{$spaces} ";

if ($outputKeys) {
$output .= self::exportInternal($key, 0);
$output .= self::exportInternal($key, $level);

$output .= ' => ';
}
Expand Down
12 changes: 2 additions & 10 deletions src/Panel/Asset/AssetCardRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,13 @@ public static function renderCard(AssetBundleView $bundle, AssetSummary $summary
/**
* Resolves the anchor id for a dependency name.
*
* Prefers the id of an already-registered bundle so cross-references jump to a real card; otherwise falls back to a
* fresh {@see \\PHPForge\\Debug\\Helper\\Text::camel2id()} pass, so the link still points to the id the bundle
* would get if it were registered later.
* Uses the same canonical {@see \\PHPForge\\Debug\\Helper\\Text::camel2id()} conversion as bundle registration.
*
* @param string $depName Fully qualified class name of the dependency.
* @param AssetSummary $summary Already-normalized summary.
* @param AssetSummary $summary Already-normalized summary, retained for backward compatibility.
*/
public static function resolveAnchor(string $depName, AssetSummary $summary): string
{
foreach ($summary->bundles as $candidate) {
if ($candidate->name === $depName) {
return $candidate->id;
}
}

return Text::camel2id($depName);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Panel/Db/DbQueryRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use function date;
use function implode;
use function in_array;
use function mb_strtoupper;
use function sprintf;
use function strtoupper;

/**
* Renders the typed cells of the queries grid for the DB debug panel.
Expand All @@ -41,7 +41,7 @@ final class DbQueryRenderer
public static function canBeExplained(string $type): bool
{
return in_array(
mb_strtoupper($type, 'utf8'),
strtoupper($type),
['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REPLACE', 'WITH'],
true,
);
Expand Down
8 changes: 4 additions & 4 deletions src/Panel/Dump/DumpCardRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use function array_map;
use function basename;
use function date;
use function floor;
use function html_entity_decode;
use function in_array;
use function intval;
use function is_int;
use function ltrim;
use function preg_match;
Expand Down Expand Up @@ -77,7 +77,7 @@ private static function formatTime(float $time): string
return '';
}

$millis = (int) (($time - floor($time)) * 1000);
$millis = intval($time * 1000) % 1000;

return date('H:i:s', (int) $time) . '.' . sprintf('%03d', $millis);
}
Expand Down Expand Up @@ -199,8 +199,8 @@ private static function sniffType(string $message): array
return ['string', 'string'];
}

if (preg_match('/^([A-Za-z_][A-Za-z0-9_\\\\]*)/', $payload, $m) === 1) {
$name = $m[1];
if (preg_match('/^[A-Za-z_][A-Za-z0-9_\\\\]*/', $payload, $m) === 1) {
$name = $m[0];

$lower = strtolower($name);

Expand Down
25 changes: 12 additions & 13 deletions src/Panel/Log/LogCellRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use function array_map;
use function date;
use function implode;
use function intdiv;
use function sprintf;
use function str_starts_with;

Expand Down Expand Up @@ -119,11 +120,11 @@ public static function renderMessageCell(LogRow $row, Closure $traceLine): strin
*/
public static function renderTimeCell(LogRow $row): string
{
$seconds = $row->time / 1000;
$timestamp = (int) $row->time;
$seconds = intdiv($timestamp, 1000);
$millis = $timestamp % 1000;

$millis = (int) (($seconds - (int) $seconds) * 1000);

return date('H:i:s.', (int) $seconds) . sprintf('%03d', $millis);
return date('H:i:s.', $seconds) . sprintf('%03d', $millis);
}

/**
Expand All @@ -133,15 +134,13 @@ public static function renderTimeCell(LogRow $row): string
*/
public static function renderTimeSincePreviousCell(LogRow $row): string
{
$diffMsTotal = $row->time - $row->timeOfPrevious;

$diffSecondsTotal = $diffMsTotal / 1000;
$diffMinutesTotal = $diffSecondsTotal / 60;
$diffHoursTotal = $diffMinutesTotal / 60;
$diffMs = (int) $diffMsTotal % 1000;
$diffSeconds = (int) $diffSecondsTotal % 60;
$diffMinutes = (int) $diffMinutesTotal % 60;
$diffHours = (int) $diffHoursTotal;
$diffMsTotal = (int) ($row->time - $row->timeOfPrevious);
$diffSecondsTotal = intdiv($diffMsTotal, 1000);
$diffMinutesTotal = intdiv($diffSecondsTotal, 60);
$diffHours = intdiv($diffMinutesTotal, 60);
$diffMs = $diffMsTotal % 1000;
$diffSeconds = $diffSecondsTotal % 60;
$diffMinutes = $diffMinutesTotal % 60;

$parts = [];

Expand Down
9 changes: 4 additions & 5 deletions src/Panel/Mail/MailCardRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
use function array_map;
use function date;
use function explode;
use function floor;
use function intdiv;
use function mb_strlen;
use function mb_strtoupper;
use function mb_substr;
use function preg_replace;
use function time;

/**
* Renders the typed mail message card consumed by the Mail panel detail view's `_item` template.
Expand Down Expand Up @@ -104,19 +103,19 @@ private static function formatTime(int $unix): array
}

if ($diff < 3600) {
$minutes = (int) floor($diff / 60);
$minutes = intdiv($diff, 60);

return ["{$minutes} min ago", $absolute];
}

if ($diff < 86400) {
$hours = (int) floor($diff / 3600);
$hours = intdiv($diff, 3600);

return ["{$hours} h ago", $absolute];
}

if ($diff < 2592000) {
$days = (int) floor($diff / 86400);
$days = intdiv($diff, 86400);

return ["{$days} d ago", $absolute];
}
Expand Down
Loading
Loading