Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SplCaster.php

function SplCaster::castFileObject

File

vendor/symfony/var-dumper/Caster/SplCaster.php, line 142

Class

SplCaster
Casts SPL related classes to array representation.

Namespace

Symfony\Component\VarDumper\Caster

Code

public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, bool $isNested) : array {
    static $map = [
        'csvControl' => 'getCsvControl',
        'flags' => 'getFlags',
        'maxLineLen' => 'getMaxLineLen',
        'fstat' => 'fstat',
        'eof' => 'eof',
        'key' => 'key',
    ];
    $prefix = Caster::PREFIX_VIRTUAL;
    foreach ($map as $key => $accessor) {
        try {
            $a[$prefix . $key] = $c->{$accessor}();
        } catch (\Exception) {
        }
    }
    if (isset($a[$prefix . 'flags'])) {
        $flagsArray = [];
        foreach (self::SPL_FILE_OBJECT_FLAGS as $value => $name) {
            if ($a[$prefix . 'flags'] & $value) {
                $flagsArray[] = $name;
            }
        }
        $a[$prefix . 'flags'] = new ConstStub(implode('|', $flagsArray), $a[$prefix . 'flags']);
    }
    if (isset($a[$prefix . 'fstat'])) {
        $a[$prefix . 'fstat'] = new CutArrayStub($a[$prefix . 'fstat'], [
            'dev',
            'ino',
            'nlink',
            'rdev',
            'blksize',
            'blocks',
        ]);
    }
    return $a;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal