[VarDumper] fix dumping uninitialized SplFileInfo
This commit is contained in:
parent
e7f70415a5
commit
b0f42333a5
@ -90,6 +90,12 @@ class SplCaster
|
|||||||
|
|
||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$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) {
|
foreach ($map as $key => $accessor) {
|
||||||
try {
|
try {
|
||||||
$a[$prefix.$key] = $c->$accessor();
|
$a[$prefix.$key] = $c->$accessor();
|
||||||
|
@ -202,6 +202,18 @@ Symfony\Component\VarDumper\Tests\Caster\MyArrayIterator {
|
|||||||
0 => 234
|
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;
|
EOTXT;
|
||||||
$this->assertDumpEquals($expected, $var);
|
$this->assertDumpEquals($expected, $var);
|
||||||
}
|
}
|
||||||
@ -211,3 +223,10 @@ class MyArrayIterator extends \ArrayIterator
|
|||||||
{
|
{
|
||||||
private $foo = 123;
|
private $foo = 123;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BadSplFileInfo extends \SplFileInfo
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user