annotate vendor/symfony/var-dumper/Caster/XmlResourceCaster.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\VarDumper\Caster;
Chris@0 13
Chris@0 14 use Symfony\Component\VarDumper\Cloner\Stub;
Chris@0 15
Chris@0 16 /**
Chris@0 17 * Casts XML resources to array representation.
Chris@0 18 *
Chris@0 19 * @author Nicolas Grekas <p@tchwork.com>
Chris@0 20 */
Chris@0 21 class XmlResourceCaster
Chris@0 22 {
Chris@17 23 private static $xmlErrors = [
Chris@0 24 XML_ERROR_NONE => 'XML_ERROR_NONE',
Chris@0 25 XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY',
Chris@0 26 XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX',
Chris@0 27 XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS',
Chris@0 28 XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN',
Chris@0 29 XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN',
Chris@0 30 XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR',
Chris@0 31 XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH',
Chris@0 32 XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE',
Chris@0 33 XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT',
Chris@0 34 XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF',
Chris@0 35 XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY',
Chris@0 36 XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF',
Chris@0 37 XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY',
Chris@0 38 XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF',
Chris@0 39 XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF',
Chris@0 40 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF',
Chris@0 41 XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI',
Chris@0 42 XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING',
Chris@0 43 XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING',
Chris@0 44 XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION',
Chris@0 45 XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING',
Chris@17 46 ];
Chris@0 47
Chris@0 48 public static function castXml($h, array $a, Stub $stub, $isNested)
Chris@0 49 {
Chris@0 50 $a['current_byte_index'] = xml_get_current_byte_index($h);
Chris@0 51 $a['current_column_number'] = xml_get_current_column_number($h);
Chris@0 52 $a['current_line_number'] = xml_get_current_line_number($h);
Chris@0 53 $a['error_code'] = xml_get_error_code($h);
Chris@0 54
Chris@0 55 if (isset(self::$xmlErrors[$a['error_code']])) {
Chris@0 56 $a['error_code'] = new ConstStub(self::$xmlErrors[$a['error_code']], $a['error_code']);
Chris@0 57 }
Chris@0 58
Chris@0 59 return $a;
Chris@0 60 }
Chris@0 61 }