Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/var-dumper/Caster/XmlReaderCaster.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 /* | |
3 * This file is part of the Symfony package. | |
4 * | |
5 * (c) Fabien Potencier <fabien@symfony.com> | |
6 * | |
7 * For the full copyright and license information, please view the LICENSE | |
8 * file that was distributed with this source code. | |
9 */ | |
10 | |
11 namespace Symfony\Component\VarDumper\Caster; | |
12 | |
13 use Symfony\Component\VarDumper\Cloner\Stub; | |
14 | |
15 /** | |
16 * Casts XmlReader class to array representation. | |
17 * | |
18 * @author Baptiste ClaviƩ <clavie.b@gmail.com> | |
19 */ | |
20 class XmlReaderCaster | |
21 { | |
22 private static $nodeTypes = array( | |
23 \XMLReader::NONE => 'NONE', | |
24 \XMLReader::ELEMENT => 'ELEMENT', | |
25 \XMLReader::ATTRIBUTE => 'ATTRIBUTE', | |
26 \XMLReader::TEXT => 'TEXT', | |
27 \XMLReader::CDATA => 'CDATA', | |
28 \XMLReader::ENTITY_REF => 'ENTITY_REF', | |
29 \XMLReader::ENTITY => 'ENTITY', | |
30 \XMLReader::PI => 'PI (Processing Instruction)', | |
31 \XMLReader::COMMENT => 'COMMENT', | |
32 \XMLReader::DOC => 'DOC', | |
33 \XMLReader::DOC_TYPE => 'DOC_TYPE', | |
34 \XMLReader::DOC_FRAGMENT => 'DOC_FRAGMENT', | |
35 \XMLReader::NOTATION => 'NOTATION', | |
36 \XMLReader::WHITESPACE => 'WHITESPACE', | |
37 \XMLReader::SIGNIFICANT_WHITESPACE => 'SIGNIFICANT_WHITESPACE', | |
38 \XMLReader::END_ELEMENT => 'END_ELEMENT', | |
39 \XMLReader::END_ENTITY => 'END_ENTITY', | |
40 \XMLReader::XML_DECLARATION => 'XML_DECLARATION', | |
41 ); | |
42 | |
43 public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $isNested) | |
44 { | |
45 $props = Caster::PREFIX_VIRTUAL.'parserProperties'; | |
46 $info = array( | |
47 'localName' => $reader->localName, | |
48 'prefix' => $reader->prefix, | |
49 'nodeType' => new ConstStub(self::$nodeTypes[$reader->nodeType], $reader->nodeType), | |
50 'depth' => $reader->depth, | |
51 'isDefault' => $reader->isDefault, | |
52 'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement, | |
53 'xmlLang' => $reader->xmlLang, | |
54 'attributeCount' => $reader->attributeCount, | |
55 'value' => $reader->value, | |
56 'namespaceURI' => $reader->namespaceURI, | |
57 'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI, | |
58 $props => array( | |
59 'LOADDTD' => $reader->getParserProperty(\XMLReader::LOADDTD), | |
60 'DEFAULTATTRS' => $reader->getParserProperty(\XMLReader::DEFAULTATTRS), | |
61 'VALIDATE' => $reader->getParserProperty(\XMLReader::VALIDATE), | |
62 'SUBST_ENTITIES' => $reader->getParserProperty(\XMLReader::SUBST_ENTITIES), | |
63 ), | |
64 ); | |
65 | |
66 if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, array(), $count)) { | |
67 $info[$props] = new EnumStub($info[$props]); | |
68 $info[$props]->cut = $count; | |
69 } | |
70 | |
71 $info = Caster::filter($info, Caster::EXCLUDE_EMPTY, array(), $count); | |
72 // +2 because hasValue and hasAttributes are always filtered | |
73 $stub->cut += $count + 2; | |
74 | |
75 return $a + $info; | |
76 } | |
77 } |