From 8ba34dafd335bfc91570274bc4517f4bdb7e46d4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 8 Jul 2020 17:20:29 +0200 Subject: [PATCH] ensure compatibility with PHP 8 stack traces --- .../Component/Cache/Adapter/PhpArrayAdapter.php | 13 ++++++++++--- .../Config/Resource/ClassExistenceResource.php | 15 ++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 6df00d1d33712..b4f6a1334289b 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -275,10 +275,17 @@ public static function throwOnRequiredClass($class) 'function' => 'spl_autoload_call', 'args' => [$class], ]; - $i = 1 + array_search($autoloadFrame, $trace, true); - if (isset($trace[$i]['function']) && !isset($trace[$i]['class'])) { - switch ($trace[$i]['function']) { + if (\PHP_VERSION_ID >= 80000 && isset($trace[1])) { + $callerFrame = $trace[1]; + } elseif (false !== $i = array_search($autoloadFrame, $trace, true)) { + $callerFrame = $trace[++$i]; + } else { + throw $e; + } + + if (isset($callerFrame['function']) && !isset($callerFrame['class'])) { + switch ($callerFrame['function']) { case 'get_class_methods': case 'get_class_vars': case 'get_parent_class': diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index fc0259f418922..f58d2a6df5f8a 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -190,12 +190,17 @@ public static function throwOnRequiredClass($class, \Exception $previous = null) 'args' => [$class], ]; - if (false === $i = array_search($autoloadFrame, $trace, true)) { + if (\PHP_VERSION_ID >= 80000 && isset($trace[1])) { + $callerFrame = $trace[1]; + $i = 2; + } elseif (false !== $i = array_search($autoloadFrame, $trace, true)) { + $callerFrame = $trace[++$i]; + } else { throw $e; } - if (isset($trace[++$i]['function']) && !isset($trace[$i]['class'])) { - switch ($trace[$i]['function']) { + if (isset($callerFrame['function']) && !isset($callerFrame['class'])) { + switch ($callerFrame['function']) { case 'get_class_methods': case 'get_class_vars': case 'get_parent_class': @@ -214,8 +219,8 @@ public static function throwOnRequiredClass($class, \Exception $previous = null) } $props = [ - 'file' => isset($trace[$i]['file']) ? $trace[$i]['file'] : null, - 'line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : null, + 'file' => isset($callerFrame['file']) ? $callerFrame['file'] : null, + 'line' => isset($callerFrame['line']) ? $callerFrame['line'] : null, 'trace' => \array_slice($trace, 1 + $i), ]; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy