8000 [VarDumper] Added support for SplFileInfo · symfony/symfony@e464fb1 · GitHub
[go: up one dir, main page]

Skip to content

Commit e464fb1

Browse files
committed
[VarDumper] Added support for SplFileInfo
1 parent 862bdf1 commit e464fb1

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,36 @@ public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, S
7272
return $a;
7373
}
7474

75+
public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNested)
76+
{
77+
$prefix = Caster::PREFIX_VIRTUAL;
78+
79+
return $a + array(
80+
$prefix.'path' => $c->getPath(),
81+
$prefix.'filename' => $c->getFilename(),
82+
$prefix.'basename' => $c->getBasename(),
83+
$prefix.'pathname' => $c->getPathname(),
84+
$prefix.'extension' => $c->getExtension(),
85+
$prefix.'realPath' => $c->getRealPath(),
86+
$prefix.'perms' => new ConstStub(sprintf('0%o', $c->getPerms()), $c->getPerms()),
87+
$prefix.'inode' => $c->getInode(),
88+
$prefix.'size' => $c->getSize(),
89+
$prefix.'owner' => $c->getOwner(),
90+
$prefix.'group' => $c->getGroup(),
91+
$prefix.'aTime' => new ConstStub(date('Y-m-d H:i:s', $c->getATime()), $c->getATime()),
92+
$prefix.'mTime' => new ConstStub(date('Y-m-d H:i:s', $c->getMTime()), $c->getMTime()),
93+
$prefix.'cTime' => new ConstStub(date('Y-m-d H:i:s', $c->getCTime()), $c->getCTime()),
94+
$prefix.'type' => $c->getType(),
95+
$prefix.'writable' => $c->isWritable(),
96+
$prefix.'readable' => $c->isReadable(),
97+
$prefix.'executable' => $c->isExecutable(),
98+
$prefix.'file' => $c->isFile(),
99+
$prefix.'dir' => $c->isDir(),
100+
$prefix.'link' => $c->isLink(),
101+
$prefix.'linkTarget' => $c->isLink() ? $c->getLinkTarget() : null,
102+
);
103+
}
104+
75105
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
76106
{
77107
$a += array(

src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ abstract class AbstractCloner implements ClonerInterface
7878

7979
'ArrayObject' => 'Symfony\Component\VarDumper\Caster\SplCaster::castArrayObject',
8080
'SplDoublyLinkedList' => 'Symfony\Component\VarDumper\Caster\SplCaster::castDoublyLinkedList',
81+
'SplFileInfo' => 'Symfony\Component\VarDumper\Caster\SplCaster::castFileInfo',
8182
'SplFixedArray' => 'Symfony\Component\VarDumper\Caster\SplCaster::castFixedArray',
8283
'SplHeap' => 'Symfony\Component\VarDumper\Caster\SplCaster::castHeap',
8384
'SplObjectStorage' => 'Symfony\Component\VarDumper\Caster\SplCaster::castObjectStorage',

0 commit comments

Comments
 (0)
0