Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 699f400

Browse filesBrowse files
[ErrorHandler] Fix parsing messages that contain anonymous classes on PHP >= 8.3.3
1 parent 526bb8b commit 699f400
Copy full SHA for 699f400

File tree

Expand file treeCollapse file tree

2 files changed

+8
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-4
lines changed

‎src/Symfony/Component/ErrorHandler/DebugClassLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/DebugClassLoader.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ private function fixReturnStatements(\ReflectionMethod $method, string $returnTy
10971097
$braces = 0;
10981098
for (; $i < $end; ++$i) {
10991099
if (!$inClosure) {
1100-
$inClosure = str_contains($code[$i], 'function (');
1100+
$inClosure = false !== strpos($code[$i], 'function (');
11011101
}
11021102

11031103
if ($inClosure) {

‎src/Symfony/Component/ErrorHandler/ErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/ErrorHandler.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,23 +457,27 @@ public function handleError(int $type, string $message, string $file, int $line)
457457
return true;
458458
}
459459
} else {
460-
if (false !== strpos($message, '@anonymous')) {
460+
if (PHP_VERSION_ID < 80303 && false !== strpos($message, '@anonymous')) {
461461
$backtrace = debug_backtrace(false, 5);
462462

463463
for ($i = 1; isset($backtrace[$i]); ++$i) {
464464
if (isset($backtrace[$i]['function'], $backtrace[$i]['args'][0])
465465
&& ('trigger_error' === $backtrace[$i]['function'] || 'user_error' === $backtrace[$i]['function'])
466466
) {
467467
if ($backtrace[$i]['args'][0] !== $message) {
468-
$message = $this->parseAnonymousClass($backtrace[$i]['args'][0]);
469-
$logMessage = $this->levels[$type].': '.$message;
468+
$message = $backtrace[$i]['args'][0];
470469
}
471470

472471
break;
473472
}
474473
}
475474
}
476475

476+
if (false !== strpos($message, "@anonymous\0")) {
477+
$message = $this->parseAnonymousClass($message);
478+
$logMessage = $this->levels[$type].': '.$message;
479+
}
480+
477481
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
478482

479483
if ($throw || $this->tracedErrors & $type) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.