From d19ede7a2cafb386be9486c580649d0f9e3d0363 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 5 Nov 2024 10:27:50 +0100 Subject: [PATCH] fix detecting anonymous exception classes on Windows and PHP 7 --- ErrorHandler.php | 2 +- Exception/FlattenException.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ErrorHandler.php b/ErrorHandler.php index 840353f..4107bae 100644 --- a/ErrorHandler.php +++ b/ErrorHandler.php @@ -806,7 +806,7 @@ private function cleanTrace(array $backtrace, int $type, string &$file, int &$li */ private function parseAnonymousClass(string $message): string { - return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', static function ($m) { + return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', static function ($m) { return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); } diff --git a/Exception/FlattenException.php b/Exception/FlattenException.php index f73842a..2532b8c 100644 --- a/Exception/FlattenException.php +++ b/Exception/FlattenException.php @@ -226,7 +226,7 @@ public function getMessage(): string public function setMessage(string $message): self { if (false !== strpos($message, "@anonymous\0")) { - $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { + $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', function ($m) { return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); }