Skip to content

Commit 0abcd46

Browse files
committed
cs
1 parent 30a91f0 commit 0abcd46

12 files changed

+22
-22
lines changed

src/Tracy/BlueScreen/BlueScreen.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private function renderActions(\Throwable $ex): array
255255
}
256256
}
257257

258-
if (preg_match('# ([\'"])((?:/|[a-z]:[/\\\\])\w[^\'"]+\.\w{2,5})\1#i', $ex->getMessage(), $m)) {
258+
if (preg_match('# ([\'"])((?:/|[a-z]:[/\\\])\w[^\'"]+\.\w{2,5})\1#i', $ex->getMessage(), $m)) {
259259
$file = $m[2];
260260
if (@is_file($file)) { // @ - may trigger error
261261
$label = 'open';
@@ -380,14 +380,14 @@ public function formatMessage(\Throwable $exception): string
380380

381381
// highlight 'string'
382382
$msg = preg_replace(
383-
'#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\\")*\S"#',
383+
'#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\")*\S"#',
384384
'<i>$0</i>',
385385
$msg,
386386
);
387387

388388
// clickable class & methods
389389
$msg = preg_replace_callback(
390-
'#(\w+\\\\[\w\\\\]+\w)(?:::(\w+))?#',
390+
'#(\w+\\\[\w\\\]+\w)(?:::(\w+))?#',
391391
function ($m) {
392392
if (isset($m[2]) && method_exists($m[1], $m[2])) {
393393
$r = new \ReflectionMethod($m[1], $m[2]);
@@ -406,7 +406,7 @@ function ($m) {
406406

407407
// clickable file name
408408
$msg = preg_replace_callback(
409-
'#([\w\\\\/.:-]+\.(?:php|phpt|phtml|latte|neon))(?|:(\d+)| on line (\d+))?#',
409+
'#([\w\\\/.:-]+\.(?:php|phpt|phtml|latte|neon))(?|:(\d+)| on line (\d+))?#',
410410
fn($m) => @is_file($m[1]) // @ - may trigger error
411411
? '<a href="' . Helpers::escapeHtml(Helpers::editorUri($m[1], isset($m[2]) ? (int) $m[2] : null)) . '" class="tracy-editor">' . $m[0] . '</a>'
412412
: $m[0],

src/Tracy/Debugger/Debugger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public static function enable(
192192
self::$logDirectory = $logDirectory ?? self::$logDirectory;
193193

194194
if (self::$logDirectory) {
195-
if (!preg_match('#([a-z]+:)?[/\\\\]#Ai', self::$logDirectory)) {
195+
if (!preg_match('#([a-z]+:)?[/\\\]#Ai', self::$logDirectory)) {
196196
self::exceptionHandler(new \RuntimeException('Logging directory must be absolute path.'));
197197
exit(255);
198198
} elseif (!is_dir(self::$logDirectory)) {

src/Tracy/Helpers.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -183,28 +183,28 @@ public static function improveException(\Throwable $e): void
183183
$message = str_replace($m[2], "but function '$arg' does not exist" . ($hint ? " (did you mean $hint?)" : ''), $message);
184184
}
185185

186-
} elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) {
186+
} elseif (preg_match('#^Call to undefined function (\S+\\\)?(\w+)\(#', $message, $m)) {
187187
$funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']);
188188
if ($hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2])) {
189189
$message = "Call to undefined function $m[2](), did you mean $hint()?";
190190
$replace = ["$m[2](", "$hint("];
191191
}
192192

193-
} elseif (preg_match('#^Call to undefined method ([\w\\\\]+)::(\w+)#', $message, $m)) {
193+
} elseif (preg_match('#^Call to undefined method ([\w\\\]+)::(\w+)#', $message, $m)) {
194194
if ($hint = self::getSuggestion(get_class_methods($m[1]) ?: [], $m[2])) {
195195
$message .= ", did you mean $hint()?";
196196
$replace = ["$m[2](", "$hint("];
197197
}
198198

199-
} elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
199+
} elseif (preg_match('#^Undefined property: ([\w\\\]+)::\$(\w+)#', $message, $m)) {
200200
$rc = new \ReflectionClass($m[1]);
201201
$items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), fn($prop) => !$prop->isStatic());
202202
if ($hint = self::getSuggestion($items, $m[2])) {
203203
$message .= ", did you mean $$hint?";
204204
$replace = ["->$m[2]", "->$hint"];
205205
}
206206

207-
} elseif (preg_match('#^Access to undeclared static property:? ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
207+
} elseif (preg_match('#^Access to undeclared static property:? ([\w\\\]+)::\$(\w+)#', $message, $m)) {
208208
$rc = new \ReflectionClass($m[1]);
209209
$items = array_filter($rc->getProperties(\ReflectionProperty::IS_STATIC), fn($prop) => $prop->isPublic());
210210
if ($hint = self::getSuggestion($items, $m[2])) {
@@ -232,7 +232,7 @@ public static function improveException(\Throwable $e): void
232232
/** @internal */
233233
public static function improveError(string $message): string
234234
{
235-
if (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
235+
if (preg_match('#^Undefined property: ([\w\\\]+)::\$(\w+)#', $message, $m)) {
236236
$rc = new \ReflectionClass($m[1]);
237237
$items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), fn($prop) => !$prop->isStatic());
238238
$hint = self::getSuggestion($items, $m[2]);

src/Tracy/Logger/Logger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function getExceptionFile(\Throwable $exception, string $level = self::EX
128128
}
129129

130130
$hash = substr(md5(serialize($data)), 0, 10);
131-
$dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
131+
$dir = strtr($this->directory . '/', '\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR);
132132
foreach (new \DirectoryIterator($this->directory) as $file) {
133133
if (strpos($file->getBasename(), $hash)) {
134134
return $dir . $file;

tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ register_shutdown_function(function () use (&$onFatalErrorCalled) {
2626
Assert::true($onFatalErrorCalled);
2727
Assert::match('ErrorException: Cannot re-assign $this in %a%
2828
Stack trace:
29-
#0 [internal function]: Tracy\\Debugger::shutdownHandler()
29+
#0 [internal function]: Tracy\Debugger::shutdownHandler()
3030
#1 {main}
3131
Tracy is unable to log error: Logging directory is not specified.
3232
', ob_get_clean());

tests/Tracy/Debugger.barDump().phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Debugger::enable();
2626

2727
register_shutdown_function(function () {
2828
$output = ob_get_clean();
29-
preg_match('#Tracy\.Debug\.init\((".*[^\\\\]")\)#', $output, $m);
29+
preg_match('#Tracy\.Debug\.init\((".*[^\\\]")\)#', $output, $m);
3030
$rawContent = str_replace('<\!--', '<!--', $m[1], $count);
3131
$rawContent = json_decode($rawContent);
3232
$panelContent = (string) DomQuery::fromHtml($rawContent)->find('#tracy-debug-panel-Tracy-dumps')[0]['data-tracy-content'];

tests/Tracy/Debugger.barDump().showLocation.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Debugger::enable();
2727

2828
register_shutdown_function(function () {
2929
$output = ob_get_clean();
30-
preg_match('#Tracy\.Debug\.init\((".*[^\\\\]")\)#', $output, $m);
30+
preg_match('#Tracy\.Debug\.init\((".*[^\\\]")\)#', $output, $m);
3131
$rawContent = json_decode($m[1]);
3232
$panelContent = (string) DomQuery::fromHtml($rawContent)->find('#tracy-debug-panel-Tracy-dumps')[0]['data-tracy-content'];
3333
Assert::match(<<<'XX'
@@ -36,7 +36,7 @@ register_shutdown_function(function () {
3636
<div class="tracy-inner tracy-DumpPanel">
3737
3838
<pre class="tracy-dump tracy-light"
39-
><a href="editor:%a%" class="tracy-dump-location" title="in file %a% on line %d%&#10;Click to open in editor">barDump('value') 📍</a
39+
><a href="editor:%a%" class="tracy-dump-location" title="in file %a% on line %d%&#10;Click to open in editor">barDump('value') 📍</a
4040
><span class="tracy-dump-string" title="5 characters"><span>'</span>value<span>'</span></span></pre>
4141
</div>
4242
%A%

tests/Tracy/Debugger.warnings.html.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Debugger::enable();
2626

2727
register_shutdown_function(function () {
2828
$output = ob_get_clean();
29-
preg_match('#Tracy\.Debug\.init\((".*[^\\\\]")\)#', $output, $m);
29+
preg_match('#Tracy\.Debug\.init\((".*[^\\\]")\)#', $output, $m);
3030
$rawContent = json_decode($m[1]);
3131
$panelContent = (string) DomQuery::fromHtml($rawContent)->find('#tracy-debug-panel-Tracy-errors')[0]['data-tracy-content'];
3232
Assert::match(<<<'XX'

tests/Tracy/Dumper.toHtml().live.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Assert::same([], Dumper::$liveSnapshot[0]);
3535

3636
// live dump of array
3737
Assert::match(
38-
'<pre class="tracy-dump" data-tracy-dump=\'[[0,null],[1,true],[2,false],[3,0],[4,{"number":"0.0"}],[5,"string"],[6,{"string":"\u0027\u0026amp;\"","length":3}],[7,{"string":"<i>\\\\x00</i>","length":1}],[8,{"number":"INF"}],[9,{"number":"-INF"}],[10,{"number":"NAN"}]]\'></pre>',
38+
'<pre class="tracy-dump" data-tracy-dump=\'[[0,null],[1,true],[2,false],[3,0],[4,{"number":"0.0"}],[5,"string"],[6,{"string":"\u0027\u0026amp;\"","length":3}],[7,{"string":"<i>\\\x00</i>","length":1}],[8,{"number":"INF"}],[9,{"number":"-INF"}],[10,{"number":"NAN"}]]\'></pre>',
3939
Dumper::toHtml([null, true, false, 0, 0.0, 'string', "'&\"", "\x00", INF, -INF, NAN], $options),
4040
);
4141

tests/Tracy/Dumper.toHtml().phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Assert::same('<pre class="tracy-dump tracy-light"><span class="tracy-dump-string
3838

3939
Assert::same('<pre class="tracy-dump tracy-light"><span class="tracy-dump-string"><span>\'</span>0<span>\'</span></span></pre>' . "\n", Dumper::toHtml('0'));
4040

41-
Assert::same('<pre class="tracy-dump tracy-light"><span class="tracy-dump-string"><span>\'</span><i>\\x00</i><span>\'</span></span></pre>' . "\n", Dumper::toHtml("\x00"));
41+
Assert::same('<pre class="tracy-dump tracy-light"><span class="tracy-dump-string"><span>\'</span><i>\x00</i><span>\'</span></span></pre>' . "\n", Dumper::toHtml("\x00"));
4242

4343
Assert::match('<pre class="tracy-dump tracy-light"
4444
><div class="tracy-dump-string" title="3 characters"><span class="tracy-dump-lq">\'</span>a<i>\n</i>' . "\n<span class=\"tracy-dump-indent\"> </span>b<span>'</span></div></pre>\n", Dumper::toHtml("a\nb"));

tests/Tracy/expected/Debugger.barDump().expect

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<div class="tracy-inner tracy-DumpPanel">
88

99
<pre class="tracy-dump tracy-light" data-tracy-snapshot='{"%d%":{"object":"stdClass","items":[["key1","val1",3],["key2",true,3]]}}' data-tracy-dump='[[0,10],[1,20.2],[2,true],[3,false],[4,null],[5,{"string":"hello \u0026lt;!-- \u0026lt;script> \u0026lt;/script>","length":29}],[6,[["key1","val1"],["key2",true]]],[7,{"ref":%d%}]]'
10-
><a href="editor://open/?file=%a%" class="tracy-dump-location" title="in file %a% on line %d%&#10;Click to open in editor">barDump($arr) 📍</a
10+
><a href="editor://open/?file=%a%" class="tracy-dump-location" title="in file %a% on line %d%&#10;Click to open in editor">barDump($arr) 📍</a
1111
></pre>
1212
<h2>String</h2>
1313

1414
<pre class="tracy-dump tracy-light" data-tracy-snapshot='[]' data-tracy-dump='{"string":"\u0026lt;a href=\"#\">test\u0026lt;/a>","length":20}'
15-
><a href="editor://open/?file=%a%" class="tracy-dump-location" title="in file %a% on line %d%&#10;Click to open in editor">barDump('&lt;a href="#">test&lt;/a>', 'String') 📍</a
15+
><a href="editor://open/?file=%a%" class="tracy-dump-location" title="in file %a% on line %d%&#10;Click to open in editor">barDump('&lt;a href="#">test&lt;/a>', 'String') 📍</a
1616
></pre>
1717
</div>
1818

tests/bootstrap.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ function getTempDir(): string
2323
{
2424
$dir = __DIR__ . '/tmp/' . getmypid();
2525

26-
if (empty($GLOBALS['\\lock'])) {
26+
if (empty($GLOBALS['\lock'])) {
2727
// garbage collector
28-
$GLOBALS['\\lock'] = $lock = fopen(__DIR__ . '/lock', 'w');
28+
$GLOBALS['\lock'] = $lock = fopen(__DIR__ . '/lock', 'w');
2929
if (rand(0, 100)) {
3030
flock($lock, LOCK_SH);
3131
@mkdir(dirname($dir));

0 commit comments

Comments
 (0)