1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-09-02 17:42:47 +02:00

Fix Utils::getClass() with PHP8 (#1563)

This commit is contained in:
Fabien Villepinte
2021-07-14 12:57:59 +02:00
committed by GitHub
parent 42384f29ba
commit 63e195046c
2 changed files with 28 additions and 1 deletions

View File

@@ -19,7 +19,15 @@ final class Utils
{
$class = \get_class($object);
return 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
if (false === ($pos = \strpos($class, "@anonymous\0"))) {
return $class;
}
if (false === ($parent = \get_parent_class($class))) {
return \substr($class, 0, $pos + 10);
}
return $parent . '@anonymous';
}
public static function substr(string $string, int $start, ?int $length = null): string