function SplCaster::castFileInfo
File
-
vendor/
symfony/ var-dumper/ Caster/ SplCaster.php, line 66
Class
- SplCaster
- Casts SPL related classes to array representation.
Namespace
Symfony\Component\VarDumper\CasterCode
public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, bool $isNested) : array {
static $map = [
'path' => 'getPath',
'filename' => 'getFilename',
'basename' => 'getBasename',
'pathname' => 'getPathname',
'extension' => 'getExtension',
'realPath' => 'getRealPath',
'aTime' => 'getATime',
'mTime' => 'getMTime',
'cTime' => 'getCTime',
'inode' => 'getInode',
'size' => 'getSize',
'perms' => 'getPerms',
'owner' => 'getOwner',
'group' => 'getGroup',
'type' => 'getType',
'writable' => 'isWritable',
'readable' => 'isReadable',
'executable' => 'isExecutable',
'file' => 'isFile',
'dir' => 'isDir',
'link' => 'isLink',
'linkTarget' => 'getLinkTarget',
];
$prefix = Caster::PREFIX_VIRTUAL;
unset($a["\x00SplFileInfo\x00fileName"]);
unset($a["\x00SplFileInfo\x00pathName"]);
try {
$c->isReadable();
} catch (\RuntimeException $e) {
if ('Object not initialized' !== $e->getMessage()) {
throw $e;
}
$a[$prefix . '⚠'] = 'The parent constructor was not called: the object is in an invalid state';
return $a;
} catch (\Error $e) {
if ('Object not initialized' !== $e->getMessage()) {
throw $e;
}
$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}();
} catch (\Exception) {
}
}
if ($a[$prefix . 'realPath'] ?? false) {
$a[$prefix . 'realPath'] = new LinkStub($a[$prefix . 'realPath']);
}
if (isset($a[$prefix . 'perms'])) {
$a[$prefix . 'perms'] = new ConstStub(\sprintf('0%o', $a[$prefix . 'perms']), $a[$prefix . 'perms']);
}
static $mapDate = [
'aTime',
'mTime',
'cTime',
];
foreach ($mapDate as $key) {
if (isset($a[$prefix . $key])) {
$a[$prefix . $key] = new ConstStub(date('Y-m-d H:i:s', $a[$prefix . $key]), $a[$prefix . $key]);
}
}
return $a;
}