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

Skip to content

Commit ef72b3e

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

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

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

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

75+
public static function castSplFileInfo(\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.'extension' => $c->getExtension(),
83+
$prefix.'basename' => $c->getBasename(),
84+
$prefix.'pathname' => $c->getPathname(),
85+
$prefix.'perms' => $c->getPerms(),
86+
$prefix.'inode' => $c->getInode(),
87+
$prefix.'size' => $c->getSize(),
88+
$prefix.'owner' => $c->getOwner(),
89+
$prefix.'group' => $c->getGroup(),
90+
$prefix.'aTime' => $c->getATime(),
91+
$prefix.'mTime' => $c->getMTime(),
92+
$prefix.'cTime' => $c->getCTime(),
93+
$prefix.'type' => $c->getType(),
94+
$prefix.'writable' => $c->isWritable(),
95+
$prefix.'readable' => $c->isReadable(),
96+
$prefix.'executable' => $c->isExecutable(),
97+
$prefix.'file' => $c->isFile(),
98+
$prefix.'dir' => $c->isDir(),
99+
$prefix.'link' => $c->isLink(),
100+
// $prefix.'linkTarget' => $c->getLinkTarget(), // Can throw a warning
101+
$prefix.'realPath' => $c->getRealPath(),
102+
// $prefix.'fileInfo' => $c->getFileInfo(), // Generate an infinite recursion loop
103+
// $prefix.'pathInfo' => $c->getPathInfo(), // Generate an infinite recursion loop
104+
);
105+
}
106+
75107
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, $isNested)
76108
{
77109
$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::castSplFileInfo',
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