[VarDumper] fix dumping uninitialized SplFileInfo

This commit is contained in:
Nicolas Grekas 2019-10-04 09:39:26 +02:00
parent e7f70415a5
commit b0f42333a5
2 changed files with 25 additions and 0 deletions

View File

@ -90,6 +90,12 @@ class SplCaster
$prefix = Caster::PREFIX_VIRTUAL;
if (false === $c->getPathname()) {
$a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state';
return $a;
}
foreach ($map as $key => $accessor) {
try {
$a[$prefix.$key] = $c->$accessor();

View File

@ -202,6 +202,18 @@ Symfony\Component\VarDumper\Tests\Caster\MyArrayIterator {
0 => 234
]
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testBadSplFileInfo()
{
$var = new BadSplFileInfo();
$expected = <<<EOTXT
Symfony\Component\VarDumper\Tests\Caster\BadSplFileInfo {
: "The parent constructor was not called: the object is in an invalid state"
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
@ -211,3 +223,10 @@ class MyArrayIterator extends \ArrayIterator
{
private $foo = 123;
}
class BadSplFileInfo extends \SplFileInfo
{
public function __construct()
{
}
}