From 0abcd46bea427ceed7dab32ebf9de6a16e5f0bd2 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 16 Jan 2025 06:01:16 +0100 Subject: [PATCH] cs --- src/Tracy/BlueScreen/BlueScreen.php | 8 ++++---- src/Tracy/Debugger/Debugger.php | 2 +- src/Tracy/Helpers.php | 10 +++++----- src/Tracy/Logger/Logger.php | 2 +- tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt | 2 +- tests/Tracy/Debugger.barDump().phpt | 2 +- tests/Tracy/Debugger.barDump().showLocation.phpt | 4 ++-- tests/Tracy/Debugger.warnings.html.phpt | 2 +- tests/Tracy/Dumper.toHtml().live.phpt | 2 +- tests/Tracy/Dumper.toHtml().phpt | 2 +- tests/Tracy/expected/Debugger.barDump().expect | 4 ++-- tests/bootstrap.php | 4 ++-- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Tracy/BlueScreen/BlueScreen.php b/src/Tracy/BlueScreen/BlueScreen.php index 0a30592bf..acdae1e4a 100644 --- a/src/Tracy/BlueScreen/BlueScreen.php +++ b/src/Tracy/BlueScreen/BlueScreen.php @@ -255,7 +255,7 @@ private function renderActions(\Throwable $ex): array } } - if (preg_match('# ([\'"])((?:/|[a-z]:[/\\\\])\w[^\'"]+\.\w{2,5})\1#i', $ex->getMessage(), $m)) { + if (preg_match('# ([\'"])((?:/|[a-z]:[/\\\])\w[^\'"]+\.\w{2,5})\1#i', $ex->getMessage(), $m)) { $file = $m[2]; if (@is_file($file)) { // @ - may trigger error $label = 'open'; @@ -380,14 +380,14 @@ public function formatMessage(\Throwable $exception): string // highlight 'string' $msg = preg_replace( - '#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\\")*\S"#', + '#\'\S(?:[^\']|\\\\\')*\S\'|"\S(?:[^"]|\\\")*\S"#', '$0', $msg, ); // clickable class & methods $msg = preg_replace_callback( - '#(\w+\\\\[\w\\\\]+\w)(?:::(\w+))?#', + '#(\w+\\\[\w\\\]+\w)(?:::(\w+))?#', function ($m) { if (isset($m[2]) && method_exists($m[1], $m[2])) { $r = new \ReflectionMethod($m[1], $m[2]); @@ -406,7 +406,7 @@ function ($m) { // clickable file name $msg = preg_replace_callback( - '#([\w\\\\/.:-]+\.(?:php|phpt|phtml|latte|neon))(?|:(\d+)| on line (\d+))?#', + '#([\w\\\/.:-]+\.(?:php|phpt|phtml|latte|neon))(?|:(\d+)| on line (\d+))?#', fn($m) => @is_file($m[1]) // @ - may trigger error ? '' . $m[0] . '' : $m[0], diff --git a/src/Tracy/Debugger/Debugger.php b/src/Tracy/Debugger/Debugger.php index e0c15229d..657076599 100644 --- a/src/Tracy/Debugger/Debugger.php +++ b/src/Tracy/Debugger/Debugger.php @@ -192,7 +192,7 @@ public static function enable( self::$logDirectory = $logDirectory ?? self::$logDirectory; if (self::$logDirectory) { - if (!preg_match('#([a-z]+:)?[/\\\\]#Ai', self::$logDirectory)) { + if (!preg_match('#([a-z]+:)?[/\\\]#Ai', self::$logDirectory)) { self::exceptionHandler(new \RuntimeException('Logging directory must be absolute path.')); exit(255); } elseif (!is_dir(self::$logDirectory)) { diff --git a/src/Tracy/Helpers.php b/src/Tracy/Helpers.php index a47d36e3e..8c0e35876 100644 --- a/src/Tracy/Helpers.php +++ b/src/Tracy/Helpers.php @@ -183,20 +183,20 @@ public static function improveException(\Throwable $e): void $message = str_replace($m[2], "but function '$arg' does not exist" . ($hint ? " (did you mean $hint?)" : ''), $message); } - } elseif (preg_match('#^Call to undefined function (\S+\\\\)?(\w+)\(#', $message, $m)) { + } elseif (preg_match('#^Call to undefined function (\S+\\\)?(\w+)\(#', $message, $m)) { $funcs = array_merge(get_defined_functions()['internal'], get_defined_functions()['user']); if ($hint = self::getSuggestion($funcs, $m[1] . $m[2]) ?: self::getSuggestion($funcs, $m[2])) { $message = "Call to undefined function $m[2](), did you mean $hint()?"; $replace = ["$m[2](", "$hint("]; } - } elseif (preg_match('#^Call to undefined method ([\w\\\\]+)::(\w+)#', $message, $m)) { + } elseif (preg_match('#^Call to undefined method ([\w\\\]+)::(\w+)#', $message, $m)) { if ($hint = self::getSuggestion(get_class_methods($m[1]) ?: [], $m[2])) { $message .= ", did you mean $hint()?"; $replace = ["$m[2](", "$hint("]; } - } elseif (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) { + } elseif (preg_match('#^Undefined property: ([\w\\\]+)::\$(\w+)#', $message, $m)) { $rc = new \ReflectionClass($m[1]); $items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), fn($prop) => !$prop->isStatic()); if ($hint = self::getSuggestion($items, $m[2])) { @@ -204,7 +204,7 @@ public static function improveException(\Throwable $e): void $replace = ["->$m[2]", "->$hint"]; } - } elseif (preg_match('#^Access to undeclared static property:? ([\w\\\\]+)::\$(\w+)#', $message, $m)) { + } elseif (preg_match('#^Access to undeclared static property:? ([\w\\\]+)::\$(\w+)#', $message, $m)) { $rc = new \ReflectionClass($m[1]); $items = array_filter($rc->getProperties(\ReflectionProperty::IS_STATIC), fn($prop) => $prop->isPublic()); if ($hint = self::getSuggestion($items, $m[2])) { @@ -232,7 +232,7 @@ public static function improveException(\Throwable $e): void /** @internal */ public static function improveError(string $message): string { - if (preg_match('#^Undefined property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) { + if (preg_match('#^Undefined property: ([\w\\\]+)::\$(\w+)#', $message, $m)) { $rc = new \ReflectionClass($m[1]); $items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), fn($prop) => !$prop->isStatic()); $hint = self::getSuggestion($items, $m[2]); diff --git a/src/Tracy/Logger/Logger.php b/src/Tracy/Logger/Logger.php index 8bf426301..0f9fd0c63 100644 --- a/src/Tracy/Logger/Logger.php +++ b/src/Tracy/Logger/Logger.php @@ -128,7 +128,7 @@ public function getExceptionFile(\Throwable $exception, string $level = self::EX } $hash = substr(md5(serialize($data)), 0, 10); - $dir = strtr($this->directory . '/', '\\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR); + $dir = strtr($this->directory . '/', '\/', DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR); foreach (new \DirectoryIterator($this->directory) as $file) { if (strpos($file->getBasename(), $hash)) { return $dir . $file; diff --git a/tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt b/tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt index bcf29eb2b..eab95076e 100644 --- a/tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt +++ b/tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt @@ -26,7 +26,7 @@ register_shutdown_function(function () use (&$onFatalErrorCalled) { Assert::true($onFatalErrorCalled); Assert::match('ErrorException: Cannot re-assign $this in %a% Stack trace: -#0 [internal function]: Tracy\\Debugger::shutdownHandler() +#0 [internal function]: Tracy\Debugger::shutdownHandler() #1 {main} Tracy is unable to log error: Logging directory is not specified. ', ob_get_clean()); diff --git a/tests/Tracy/Debugger.barDump().phpt b/tests/Tracy/Debugger.barDump().phpt index 0135d13ca..8884acfa3 100644 --- a/tests/Tracy/Debugger.barDump().phpt +++ b/tests/Tracy/Debugger.barDump().phpt @@ -26,7 +26,7 @@ Debugger::enable(); register_shutdown_function(function () { $output = ob_get_clean(); - preg_match('#Tracy\.Debug\.init\((".*[^\\\\]")\)#', $output, $m); + preg_match('#Tracy\.Debug\.init\((".*[^\\\]")\)#', $output, $m); $rawContent = str_replace('<\!--', '