From ab45e2aaae2e612d4fb8646edde028fd754b4f2b Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 5 Sep 2020 19:37:15 +0200 Subject: [PATCH] [VarDumper] Fix caster for invalid SplFileInfo objects on php 8. --- .../Component/VarDumper/Caster/SplCaster.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index 53df3de239..7ecbb577d2 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -92,10 +92,24 @@ class SplCaster unset($a["\0SplFileInfo\0fileName"]); unset($a["\0SplFileInfo\0pathName"]); - if (false === $c->getPathname()) { - $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; + if (\PHP_VERSION_ID < 80000) { + if (false === $c->getPathname()) { + $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; - return $a; + return $a; + } + } else { + try { + $c->isReadable(); + } catch (\RuntimeException $e) { + if ('Object not initialized' !== $e->getMessage()) { + throw $e; + } + + $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; + + return $a; + } } foreach ($map as $key => $accessor) {