Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f702d1e

Browse filesBrowse files
[VarDumper] fix dumping uninitialized SplFileInfo
1 parent e7f7041 commit f702d1e
Copy full SHA for f702d1e

File tree

Expand file treeCollapse file tree

2 files changed

+28
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/SplCaster.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNe
9090

9191
$prefix = Caster::PREFIX_VIRTUAL;
9292

93+
if (false === $c->getPathname()) {
94+
$a[$prefix.''] = 'The parent constructor was not called: the object is in an invalid state';
95+
96+
return $a;
97+
}
98+
9399
foreach ($map as $key => $accessor) {
94100
try {
95101
$a[$prefix.$key] = $c->$accessor();

‎src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ public function testArrayIterator()
202202
0 => 234
203203
]
204204
}
205+
EOTXT;
206+
$this->assertDumpEquals($expected, $var);
207+
}
208+
209+
public function testBadSplFileInfo()
210+
{
211+
if (\defined('HHVM_VERSION')) {
212+
$this->markTestSkipped('HHVM as different internal details.');
213+
}
214+
$var = new BadSplFileInfo();
215+
216+
$expected = <<<EOTXT
217+
Symfony\Component\VarDumper\Tests\Caster\BadSplFileInfo {
218+
⚠: "The parent constructor was not called: the object is in an invalid state"
219+
}
205220
EOTXT;
206221
$this->assertDumpEquals($expected, $var);
207222
}
@@ -211,3 +226,10 @@ class MyArrayIterator extends \ArrayIterator
211226
{
212227
private $foo = 123;
213228
}
229+
230+
class BadSplFileInfo extends \SplFileInfo
231+
{
232+
public function __construct()
233+
{
234+
}
235+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.