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

Breadcrumb

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

function XmlReaderCaster::castXmlReader

File

vendor/symfony/var-dumper/Caster/XmlReaderCaster.php, line 46

Class

XmlReaderCaster
Casts XmlReader class to array representation.

Namespace

Symfony\Component\VarDumper\Caster

Code

public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, bool $isNested) : array {
    try {
        $properties = [
            'LOADDTD' => @$reader->getParserProperty(\XMLReader::LOADDTD),
            'DEFAULTATTRS' => @$reader->getParserProperty(\XMLReader::DEFAULTATTRS),
            'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE),
            'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES),
        ];
    } catch (\Error) {
        $properties = [
            'LOADDTD' => false,
            'DEFAULTATTRS' => false,
            'VALIDATE' => false,
            'SUBST_ENTITIES' => false,
        ];
    }
    $props = Caster::PREFIX_VIRTUAL . 'parserProperties';
    $info = [
        'localName' => $reader->localName,
        'prefix' => $reader->prefix,
        'nodeType' => new ConstStub(self::NODE_TYPES[$reader->nodeType], $reader->nodeType),
        'depth' => $reader->depth,
        'isDefault' => $reader->isDefault,
        'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement,
        'xmlLang' => $reader->xmlLang,
        'attributeCount' => $reader->attributeCount,
        'value' => $reader->value,
        'namespaceURI' => $reader->namespaceURI,
        'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI,
        $props => $properties,
    ];
    if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) {
        $info[$props] = new EnumStub($info[$props]);
        $info[$props]->cut = $count;
    }
    $a = Caster::filter($a, Caster::EXCLUDE_UNINITIALIZED, [], $count);
    $info = Caster::filter($info, Caster::EXCLUDE_EMPTY, [], $count);
    // +2 because hasValue and hasAttributes are always filtered
    $stub->cut += $count + 2;
    return $a + $info;
}

API Navigation

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