Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  Fix PHP 8 deprecations
  ensure compatibility with PHP 8 stack traces
  • Loading branch information
nicolas-grekas committed Jul 8, 2020
2 parents 8832a6f + acdf1bc commit 06ae0de
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Resource/ClassExistenceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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),
];

Expand Down

0 comments on commit 06ae0de

Please sign in to comment.