Skip to content

Commit ab45e2a

Browse files
committed
[VarDumper] Fix caster for invalid SplFileInfo objects on php 8.
1 parent 63eab44 commit ab45e2a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Symfony/Component/VarDumper/Caster/SplCaster.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,24 @@ public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNe
9292
unset($a["\0SplFileInfo\0fileName"]);
9393
unset($a["\0SplFileInfo\0pathName"]);
9494

95-
if (false === $c->getPathname()) {
96-
$a[$prefix.''] = 'The parent constructor was not called: the object is in an invalid state';
95+
if (\PHP_VERSION_ID < 80000) {
96+
if (false === $c->getPathname()) {
97+
$a[$prefix.''] = 'The parent constructor was not called: the object is in an invalid state';
9798

98-
return $a;
99+
return $a;
100+
}
101+
} else {
102+
try {
103+
$c->isReadable();
104+
} catch (\RuntimeException $e) {
105+
if ('Object not initialized' !== $e->getMessage()) {
106+
throw $e;
107+
}
108+
109+
$a[$prefix.''] = 'The parent constructor was not called: the object is in an invalid state';
110+
111+
return $a;
112+
}
99113
}
100114

101115
foreach ($map as $key => $accessor) {

0 commit comments

Comments
 (0)