bug #33841 [VarDumper] fix dumping uninitialized SplFileInfo (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[VarDumper] fix dumping uninitialized SplFileInfo
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix https://github.com/bobthecow/psysh/issues/570
| License | MIT
| Doc PR | -
Commits
-------
b0f42333a5
[VarDumper] fix dumping uninitialized SplFileInfo
This commit is contained in:
commit
5c4f2a972a
@ -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();
|
||||
|
@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user