Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [DependencyInjection] Fix computing error messages involving service locators
  [Serializer] Fix unknown types normalization type when know type
  [ErrorHandler] Fix parsing messages that contain anonymous classes on PHP >= 8.3.3
  [Validator] Review Romanian (ro) translations
  [Console] Fix display of Table on Windows OS
  [FrameworkBundle] Fix config builder with extensions extended in `build()`
  [WebProfilerBundle] disable turbo in web profiler toolbar to avoid link prefetching
  explicitly cast boolean SSL stream options
  return the unchanged text if preg_replace_callback() fails
  the 'use_notify' option is on the factory, not on the postgres connection class
  review translations
  • Loading branch information
nicolas-grekas committed Feb 22, 2024
2 parents 3c36010 + 90b1d77 commit c725219
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DebugClassLoader.php
Expand Up @@ -1133,7 +1133,7 @@ private function fixReturnStatements(\ReflectionMethod $method, string $returnTy
$braces = 0;
for (; $i < $end; ++$i) {
if (!$inClosure) {
$inClosure = str_contains($code[$i], 'function (');
$inClosure = false !== strpos($code[$i], 'function (');
}

if ($inClosure) {
Expand Down
10 changes: 7 additions & 3 deletions ErrorHandler.php
Expand Up @@ -432,23 +432,27 @@ public function handleError(int $type, string $message, string $file, int $line)
return true;
}
} else {
if (str_contains($message, '@anonymous')) {
if (PHP_VERSION_ID < 80303 && str_contains($message, '@anonymous')) {
$backtrace = debug_backtrace(false, 5);

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

break;
}
}
}

if (false !== strpos($message, "@anonymous\0")) {
$message = $this->parseAnonymousClass($message);
$logMessage = $this->levels[$type].': '.$message;
}

$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);

if ($throw || $this->tracedErrors & $type) {
Expand Down
2 changes: 1 addition & 1 deletion ErrorRenderer/HtmlErrorRenderer.php
Expand Up @@ -301,7 +301,7 @@ private function fixCodeMarkup(string $line): string

private function formatFileFromText(string $text): string
{
return preg_replace_callback('/in ("|&quot;)?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', fn ($match) => 'in '.$this->formatFile($match[2], $match[3]), $text);
return preg_replace_callback('/in ("|&quot;)?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', fn ($match) => 'in '.$this->formatFile($match[2], $match[3]), $text) ?? $text;
}

private function formatLogMessage(string $message, array $context): string
Expand Down

0 comments on commit c725219

Please sign in to comment.