[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * This file is part of the Symfony package. 4 * 5 * (c) Fabien Potencier <[email protected]> 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Ʃ <[email protected]> 19 * 20 * @final 21 */ 22 class XmlReaderCaster 23 { 24 private const NODE_TYPES = [ 25 \XMLReader::NONE => 'NONE', 26 \XMLReader::ELEMENT => 'ELEMENT', 27 \XMLReader::ATTRIBUTE => 'ATTRIBUTE', 28 \XMLReader::TEXT => 'TEXT', 29 \XMLReader::CDATA => 'CDATA', 30 \XMLReader::ENTITY_REF => 'ENTITY_REF', 31 \XMLReader::ENTITY => 'ENTITY', 32 \XMLReader::PI => 'PI (Processing Instruction)', 33 \XMLReader::COMMENT => 'COMMENT', 34 \XMLReader::DOC => 'DOC', 35 \XMLReader::DOC_TYPE => 'DOC_TYPE', 36 \XMLReader::DOC_FRAGMENT => 'DOC_FRAGMENT', 37 \XMLReader::NOTATION => 'NOTATION', 38 \XMLReader::WHITESPACE => 'WHITESPACE', 39 \XMLReader::SIGNIFICANT_WHITESPACE => 'SIGNIFICANT_WHITESPACE', 40 \XMLReader::END_ELEMENT => 'END_ELEMENT', 41 \XMLReader::END_ENTITY => 'END_ENTITY', 42 \XMLReader::XML_DECLARATION => 'XML_DECLARATION', 43 ]; 44 45 public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, bool $isNested) 46 { 47 try { 48 $properties = [ 49 'LOADDTD' => @$reader->getParserProperty(\XMLReader::LOADDTD), 50 'DEFAULTATTRS' => @$reader->getParserProperty(\XMLReader::DEFAULTATTRS), 51 'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE), 52 'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES), 53 ]; 54 } catch (\Error $e) { 55 $properties = [ 56 'LOADDTD' => false, 57 'DEFAULTATTRS' => false, 58 'VALIDATE' => false, 59 'SUBST_ENTITIES' => false, 60 ]; 61 } 62 63 $props = Caster::PREFIX_VIRTUAL.'parserProperties'; 64 $info = [ 65 'localName' => $reader->localName, 66 'prefix' => $reader->prefix, 67 'nodeType' => new ConstStub(self::NODE_TYPES[$reader->nodeType], $reader->nodeType), 68 'depth' => $reader->depth, 69 'isDefault' => $reader->isDefault, 70 'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement, 71 'xmlLang' => $reader->xmlLang, 72 'attributeCount' => $reader->attributeCount, 73 'value' => $reader->value, 74 'namespaceURI' => $reader->namespaceURI, 75 'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI, 76 $props => $properties, 77 ]; 78 79 if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) { 80 $info[$props] = new EnumStub($info[$props]); 81 $info[$props]->cut = $count; 82 } 83 84 $info = Caster::filter($info, Caster::EXCLUDE_EMPTY, [], $count); 85 // +2 because hasValue and hasAttributes are always filtered 86 $stub->cut += $count + 2; 87 88 return $a + $info; 89 } 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |