@@ -33,76 +33,76 @@ discard block |
||
33 | 33 | * @throws InvalidXmlException When parsing of XML with schema or callable produces any errors unrelated to the XML parsing itself |
34 | 34 | * @throws XmlParsingException When parsing of XML file returns error |
35 | 35 | */ |
36 | - public static function load( $content, Config $config = null ) { |
|
37 | - if ( !extension_loaded( 'dom' ) ) { |
|
38 | - throw new RuntimeException( 'Extension DOM is required.' ); |
|
36 | + public static function load($content, Config $config = null) { |
|
37 | + if (!extension_loaded('dom')) { |
|
38 | + throw new RuntimeException('Extension DOM is required.'); |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( is_null( $config ) ) { |
|
41 | + if (is_null($config)) { |
|
42 | 42 | $config = new Config(); |
43 | 43 | } |
44 | 44 | |
45 | - $internalErrors = libxml_use_internal_errors( true ); |
|
45 | + $internalErrors = libxml_use_internal_errors(true); |
|
46 | 46 | $disableEntities = libxml_disable_entity_loader(); |
47 | 47 | libxml_clear_errors(); |
48 | 48 | |
49 | - $dom = new DOMDocument( '1.0', 'UTF-8' ); |
|
49 | + $dom = new DOMDocument('1.0', 'UTF-8'); |
|
50 | 50 | $dom->validateOnParse = true; |
51 | 51 | |
52 | - if ( is_string( $config->getSetRootElement() ) && !empty( $config->getSetRootElement() ) ) { |
|
52 | + if (is_string($config->getSetRootElement()) && !empty($config->getSetRootElement())) { |
|
53 | 53 | $content = "<{$config->getSetRootElement()}>$content</{$config->getSetRootElement()}>"; |
54 | 54 | } |
55 | 55 | |
56 | - $res = $dom->loadXML( $content, $config->getXML_OPTIONS() ); |
|
56 | + $res = $dom->loadXML($content, $config->getXML_OPTIONS()); |
|
57 | 57 | |
58 | - if ( !$res ) { |
|
59 | - libxml_disable_entity_loader( $disableEntities ); |
|
58 | + if (!$res) { |
|
59 | + libxml_disable_entity_loader($disableEntities); |
|
60 | 60 | |
61 | - throw new XmlParsingException( implode( "\n", static::getXmlErrors( $internalErrors ) ) ); |
|
61 | + throw new XmlParsingException(implode("\n", static::getXmlErrors($internalErrors))); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $dom->normalizeDocument(); |
65 | 65 | |
66 | - libxml_use_internal_errors( $internalErrors ); |
|
67 | - libxml_disable_entity_loader( $disableEntities ); |
|
66 | + libxml_use_internal_errors($internalErrors); |
|
67 | + libxml_disable_entity_loader($disableEntities); |
|
68 | 68 | |
69 | - foreach ( $dom->childNodes as $child ) { |
|
70 | - if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType && !$config->getAllowDocumentType() ) { |
|
71 | - throw new XmlParsingException( 'Document types are not allowed.' ); |
|
69 | + foreach ($dom->childNodes as $child) { |
|
70 | + if (XML_DOCUMENT_TYPE_NODE === $child->nodeType && !$config->getAllowDocumentType()) { |
|
71 | + throw new XmlParsingException('Document types are not allowed.'); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if ( null !== $config->getSchemaOrCallable() ) { |
|
76 | - $internalErrors = libxml_use_internal_errors( true ); |
|
75 | + if (null !== $config->getSchemaOrCallable()) { |
|
76 | + $internalErrors = libxml_use_internal_errors(true); |
|
77 | 77 | libxml_clear_errors(); |
78 | 78 | |
79 | 79 | $e = null; |
80 | - if ( is_callable( $config->getSchemaOrCallable() ) ) { |
|
80 | + if (is_callable($config->getSchemaOrCallable())) { |
|
81 | 81 | try { |
82 | - $valid = call_user_func( $config->getSchemaOrCallable(), $dom, $internalErrors ); |
|
83 | - } catch ( Exception $e ) { |
|
82 | + $valid = call_user_func($config->getSchemaOrCallable(), $dom, $internalErrors); |
|
83 | + } catch (Exception $e) { |
|
84 | 84 | $valid = false; |
85 | 85 | } |
86 | - } elseif ( !is_array( $config->getSchemaOrCallable() ) && is_file( (string)$config->getSchemaOrCallable() ) ) { |
|
87 | - $schemaSource = file_get_contents( (string)$config->getSchemaOrCallable() ); |
|
88 | - $valid = @$dom->schemaValidateSource( $schemaSource ); |
|
86 | + } elseif (!is_array($config->getSchemaOrCallable()) && is_file((string) $config->getSchemaOrCallable())) { |
|
87 | + $schemaSource = file_get_contents((string) $config->getSchemaOrCallable()); |
|
88 | + $valid = @$dom->schemaValidateSource($schemaSource); |
|
89 | 89 | } else { |
90 | - libxml_use_internal_errors( $internalErrors ); |
|
90 | + libxml_use_internal_errors($internalErrors); |
|
91 | 91 | |
92 | - throw new XmlParsingException( 'The schemaOrCallable argument has to be a valid path to XSD file or callable.' ); |
|
92 | + throw new XmlParsingException('The schemaOrCallable argument has to be a valid path to XSD file or callable.'); |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( !$valid ) { |
|
96 | - $messages = static::getXmlErrors( $internalErrors ); |
|
97 | - if ( empty( $messages ) ) { |
|
98 | - throw new InvalidXmlException( 'The XML is not valid.', 0, $e ); |
|
95 | + if (!$valid) { |
|
96 | + $messages = static::getXmlErrors($internalErrors); |
|
97 | + if (empty($messages)) { |
|
98 | + throw new InvalidXmlException('The XML is not valid.', 0, $e); |
|
99 | 99 | } |
100 | - throw new XmlParsingException( implode( "\n", $messages ), 0, $e ); |
|
100 | + throw new XmlParsingException(implode("\n", $messages), 0, $e); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | 104 | libxml_clear_errors(); |
105 | - libxml_use_internal_errors( $internalErrors ); |
|
105 | + libxml_use_internal_errors($internalErrors); |
|
106 | 106 | |
107 | 107 | return $dom; |
108 | 108 | } |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - private static function getXmlErrors( $internalErrors ) { |
|
115 | + private static function getXmlErrors($internalErrors) { |
|
116 | 116 | $errors = []; |
117 | - foreach ( libxml_get_errors() as $error ) { |
|
117 | + foreach (libxml_get_errors() as $error) { |
|
118 | 118 | $errors[] = sprintf( |
119 | 119 | '[%s %s] %s (in %s - line %d, column %d)', |
120 | 120 | LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', |
121 | 121 | $error->code, |
122 | - trim( $error->message ), |
|
122 | + trim($error->message), |
|
123 | 123 | $error->file ?: 'n/a', |
124 | 124 | $error->line, |
125 | 125 | $error->column |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | libxml_clear_errors(); |
130 | - libxml_use_internal_errors( $internalErrors ); |
|
130 | + libxml_use_internal_errors($internalErrors); |
|
131 | 131 | |
132 | 132 | return $errors; |
133 | 133 | } |
@@ -25,39 +25,39 @@ discard block |
||
25 | 25 | const regexpEntity = '/&#x([0-1]{0,1}[0-9A-F]{1,2})/u'; //  |
26 | 26 | const regexpAscii = '/([\x{00}-\x{1F}\x{7F}]{1})/u'; |
27 | 27 | protected static $asciiPlaceHoldMap = [ |
28 | - '00' => [ 'symbol' => 'NULL', 'placeHold' => '', 'numeral' => 0x00 ], |
|
29 | - '01' => [ 'symbol' => 'SOH', 'placeHold' => '', 'numeral' => 0x01 ], |
|
30 | - '02' => [ 'symbol' => 'STX', 'placeHold' => '', 'numeral' => 0x02 ], |
|
31 | - '03' => [ 'symbol' => 'ETX', 'placeHold' => '', 'numeral' => 0x03 ], |
|
32 | - '04' => [ 'symbol' => 'EOT', 'placeHold' => '', 'numeral' => 0x04 ], |
|
33 | - '05' => [ 'symbol' => 'ENQ', 'placeHold' => '', 'numeral' => 0x05 ], |
|
34 | - '06' => [ 'symbol' => 'ACK', 'placeHold' => '', 'numeral' => 0x06 ], |
|
35 | - '07' => [ 'symbol' => 'BEL', 'placeHold' => '', 'numeral' => 0x07 ], |
|
36 | - '08' => [ 'symbol' => 'BS', 'placeHold' => '', 'numeral' => 0x08 ], |
|
37 | - '09' => [ 'symbol' => 'HT', 'placeHold' => '', 'numeral' => 0x09 ], |
|
38 | - '0A' => [ 'symbol' => 'LF', 'placeHold' => '', 'numeral' => 0x0A ], |
|
39 | - '0B' => [ 'symbol' => 'VT', 'placeHold' => '', 'numeral' => 0x0B ], |
|
40 | - '0C' => [ 'symbol' => 'FF', 'placeHold' => '', 'numeral' => 0x0C ], |
|
41 | - '0D' => [ 'symbol' => 'CR', 'placeHold' => '', 'numeral' => 0x0D ], |
|
42 | - '0E' => [ 'symbol' => 'SO', 'placeHold' => '', 'numeral' => 0x0E ], |
|
43 | - '0F' => [ 'symbol' => 'SI', 'placeHold' => '', 'numeral' => 0x0F ], |
|
44 | - '10' => [ 'symbol' => 'DLE', 'placeHold' => '', 'numeral' => 0x10 ], |
|
45 | - '11' => [ 'symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x11 ], |
|
46 | - '12' => [ 'symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x12 ], |
|
47 | - '13' => [ 'symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x13 ], |
|
48 | - '14' => [ 'symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x14 ], |
|
49 | - '15' => [ 'symbol' => 'NAK', 'placeHold' => '', 'numeral' => 0x15 ], |
|
50 | - '16' => [ 'symbol' => 'SYN', 'placeHold' => '', 'numeral' => 0x16 ], |
|
51 | - '17' => [ 'symbol' => 'ETB', 'placeHold' => '', 'numeral' => 0x17 ], |
|
52 | - '18' => [ 'symbol' => 'CAN', 'placeHold' => '', 'numeral' => 0x18 ], |
|
53 | - '19' => [ 'symbol' => 'EM', 'placeHold' => '', 'numeral' => 0x19 ], |
|
54 | - '1A' => [ 'symbol' => 'SUB', 'placeHold' => '', 'numeral' => 0x1A ], |
|
55 | - '1B' => [ 'symbol' => 'ESC', 'placeHold' => '', 'numeral' => 0x1B ], |
|
56 | - '1C' => [ 'symbol' => 'FS', 'placeHold' => '', 'numeral' => 0x1C ], |
|
57 | - '1D' => [ 'symbol' => 'GS', 'placeHold' => '', 'numeral' => 0x1D ], |
|
58 | - '1E' => [ 'symbol' => 'RS', 'placeHold' => '', 'numeral' => 0x1E ], |
|
59 | - '1F' => [ 'symbol' => 'US', 'placeHold' => '', 'numeral' => 0x1F ], |
|
60 | - '7F' => [ 'symbol' => 'DEL', 'placeHold' => '', 'numeral' => 0x7F ], |
|
28 | + '00' => ['symbol' => 'NULL', 'placeHold' => '', 'numeral' => 0x00], |
|
29 | + '01' => ['symbol' => 'SOH', 'placeHold' => '', 'numeral' => 0x01], |
|
30 | + '02' => ['symbol' => 'STX', 'placeHold' => '', 'numeral' => 0x02], |
|
31 | + '03' => ['symbol' => 'ETX', 'placeHold' => '', 'numeral' => 0x03], |
|
32 | + '04' => ['symbol' => 'EOT', 'placeHold' => '', 'numeral' => 0x04], |
|
33 | + '05' => ['symbol' => 'ENQ', 'placeHold' => '', 'numeral' => 0x05], |
|
34 | + '06' => ['symbol' => 'ACK', 'placeHold' => '', 'numeral' => 0x06], |
|
35 | + '07' => ['symbol' => 'BEL', 'placeHold' => '', 'numeral' => 0x07], |
|
36 | + '08' => ['symbol' => 'BS', 'placeHold' => '', 'numeral' => 0x08], |
|
37 | + '09' => ['symbol' => 'HT', 'placeHold' => '', 'numeral' => 0x09], |
|
38 | + '0A' => ['symbol' => 'LF', 'placeHold' => '', 'numeral' => 0x0A], |
|
39 | + '0B' => ['symbol' => 'VT', 'placeHold' => '', 'numeral' => 0x0B], |
|
40 | + '0C' => ['symbol' => 'FF', 'placeHold' => '', 'numeral' => 0x0C], |
|
41 | + '0D' => ['symbol' => 'CR', 'placeHold' => '', 'numeral' => 0x0D], |
|
42 | + '0E' => ['symbol' => 'SO', 'placeHold' => '', 'numeral' => 0x0E], |
|
43 | + '0F' => ['symbol' => 'SI', 'placeHold' => '', 'numeral' => 0x0F], |
|
44 | + '10' => ['symbol' => 'DLE', 'placeHold' => '', 'numeral' => 0x10], |
|
45 | + '11' => ['symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x11], |
|
46 | + '12' => ['symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x12], |
|
47 | + '13' => ['symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x13], |
|
48 | + '14' => ['symbol' => 'DC', 'placeHold' => '', 'numeral' => 0x14], |
|
49 | + '15' => ['symbol' => 'NAK', 'placeHold' => '', 'numeral' => 0x15], |
|
50 | + '16' => ['symbol' => 'SYN', 'placeHold' => '', 'numeral' => 0x16], |
|
51 | + '17' => ['symbol' => 'ETB', 'placeHold' => '', 'numeral' => 0x17], |
|
52 | + '18' => ['symbol' => 'CAN', 'placeHold' => '', 'numeral' => 0x18], |
|
53 | + '19' => ['symbol' => 'EM', 'placeHold' => '', 'numeral' => 0x19], |
|
54 | + '1A' => ['symbol' => 'SUB', 'placeHold' => '', 'numeral' => 0x1A], |
|
55 | + '1B' => ['symbol' => 'ESC', 'placeHold' => '', 'numeral' => 0x1B], |
|
56 | + '1C' => ['symbol' => 'FS', 'placeHold' => '', 'numeral' => 0x1C], |
|
57 | + '1D' => ['symbol' => 'GS', 'placeHold' => '', 'numeral' => 0x1D], |
|
58 | + '1E' => ['symbol' => 'RS', 'placeHold' => '', 'numeral' => 0x1E], |
|
59 | + '1F' => ['symbol' => 'US', 'placeHold' => '', 'numeral' => 0x1F], |
|
60 | + '7F' => ['symbol' => 'DEL', 'placeHold' => '', 'numeral' => 0x7F], |
|
61 | 61 | ]; |
62 | 62 | |
63 | 63 | /** |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | * @throws InvalidXmlException |
77 | 77 | * @throws XmlParsingException |
78 | 78 | */ |
79 | - protected function __construct( $html, $isXmlFragment ) { |
|
80 | - $html = $this->removeNotPrintableChars( $html ); |
|
79 | + protected function __construct($html, $isXmlFragment) { |
|
80 | + $html = $this->removeNotPrintableChars($html); |
|
81 | 81 | $this->isXmlFragment = $isXmlFragment; |
82 | 82 | |
83 | 83 | $this->dom = XmlDomLoader::load( |
84 | 84 | $html, |
85 | 85 | new Config( |
86 | - ( $isXmlFragment ? self::fragmentDocumentRoot : null ), |
|
86 | + ($isXmlFragment ? self::fragmentDocumentRoot : null), |
|
87 | 87 | true, |
88 | 88 | LIBXML_NONET | LIBXML_NOBLANKS |
89 | 89 | ) |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @throws InvalidXmlException |
105 | 105 | * @throws XmlParsingException |
106 | 106 | */ |
107 | - public static function parse( $html, $isXmlFragment = false ) { |
|
108 | - $parser = new static( $html, $isXmlFragment ); |
|
107 | + public static function parse($html, $isXmlFragment = false) { |
|
108 | + $parser = new static($html, $isXmlFragment); |
|
109 | 109 | |
110 | 110 | return $parser->extractNodes(); |
111 | 111 | } |
@@ -118,36 +118,36 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - protected function removeNotPrintableChars( $seg ) { |
|
121 | + protected function removeNotPrintableChars($seg) { |
|
122 | 122 | |
123 | - preg_match_all( self::regexpAscii, $seg, $matches ); |
|
123 | + preg_match_all(self::regexpAscii, $seg, $matches); |
|
124 | 124 | |
125 | - if ( !empty( $matches[ 1 ] ) ) { |
|
125 | + if (!empty($matches[1])) { |
|
126 | 126 | $test_src = $seg; |
127 | - foreach ( $matches[ 1 ] as $v ) { |
|
128 | - $key = sprintf( "%02X", ord( $v ) ); |
|
129 | - $hexNum = sprintf( "/(\\x{%s})/u", $key ); |
|
130 | - $test_src = preg_replace( $hexNum, self::$asciiPlaceHoldMap[ $key ][ 'placeHold' ], $test_src, 1 ); |
|
127 | + foreach ($matches[1] as $v) { |
|
128 | + $key = sprintf("%02X", ord($v)); |
|
129 | + $hexNum = sprintf("/(\\x{%s})/u", $key); |
|
130 | + $test_src = preg_replace($hexNum, self::$asciiPlaceHoldMap[$key]['placeHold'], $test_src, 1); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $seg = $test_src; |
134 | 134 | } |
135 | 135 | |
136 | - preg_match_all( self::regexpEntity, $seg, $matches ); |
|
136 | + preg_match_all(self::regexpEntity, $seg, $matches); |
|
137 | 137 | |
138 | - if ( !empty( $matches[ 1 ] ) ) { |
|
138 | + if (!empty($matches[1])) { |
|
139 | 139 | $test_src = $seg; |
140 | - foreach ( $matches[ 1 ] as $v ) { |
|
141 | - $byte = sprintf( "%02X", hexdec( $v ) ); |
|
142 | - if ( $byte[ 0 ] == '0' ) { |
|
143 | - $regexp = '/&#x([' . $byte[ 0 ] . ']?' . $byte[ 1 ] . ');/u'; |
|
140 | + foreach ($matches[1] as $v) { |
|
141 | + $byte = sprintf("%02X", hexdec($v)); |
|
142 | + if ($byte[0] == '0') { |
|
143 | + $regexp = '/&#x(['.$byte[0].']?'.$byte[1].');/u'; |
|
144 | 144 | } else { |
145 | - $regexp = '/&#x(' . $byte . ');/u'; |
|
145 | + $regexp = '/&#x('.$byte.');/u'; |
|
146 | 146 | } |
147 | 147 | |
148 | - $key = sprintf( "%02X", hexdec( $v ) ); |
|
149 | - if ( array_key_exists( $key, self::$asciiPlaceHoldMap ) ) { |
|
150 | - $test_src = preg_replace( $regexp, self::$asciiPlaceHoldMap[ $key ][ 'placeHold' ], $test_src ); |
|
148 | + $key = sprintf("%02X", hexdec($v)); |
|
149 | + if (array_key_exists($key, self::$asciiPlaceHoldMap)) { |
|
150 | + $test_src = preg_replace($regexp, self::$asciiPlaceHoldMap[$key]['placeHold'], $test_src); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | } |
@@ -164,20 +164,20 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return ArrayObject |
166 | 166 | */ |
167 | - protected function mapElements( DOMNodeList $elementList, ArrayObject $elements ) { |
|
167 | + protected function mapElements(DOMNodeList $elementList, ArrayObject $elements) { |
|
168 | 168 | |
169 | - for ( $i = 0; $i < $elementList->length; $i++ ) { |
|
169 | + for ($i = 0; $i < $elementList->length; $i++) { |
|
170 | 170 | |
171 | - $element = $elementList->item( $i ); |
|
171 | + $element = $elementList->item($i); |
|
172 | 172 | |
173 | - $elements[] = (object)[ |
|
174 | - 'node' => $this->dom->saveXML( $element ), |
|
173 | + $elements[] = (object) [ |
|
174 | + 'node' => $this->dom->saveXML($element), |
|
175 | 175 | 'tagName' => $element->nodeName, |
176 | - 'attributes' => $this->getAttributes( $element ), |
|
177 | - 'text' => ( $element instanceof DOMText ) ? $element->textContent : null, |
|
178 | - 'self_closed' => ( $element instanceof DOMText ) ? null : !$element->hasChildNodes(), |
|
179 | - 'has_children' => ( $element instanceof DOMText ) ? null : $element->hasChildNodes(), |
|
180 | - 'inner_html' => $element->hasChildNodes() ? $this->mapElements( $element->childNodes, new ArrayObject() ) : new ArrayObject() |
|
176 | + 'attributes' => $this->getAttributes($element), |
|
177 | + 'text' => ($element instanceof DOMText) ? $element->textContent : null, |
|
178 | + 'self_closed' => ($element instanceof DOMText) ? null : !$element->hasChildNodes(), |
|
179 | + 'has_children' => ($element instanceof DOMText) ? null : $element->hasChildNodes(), |
|
180 | + 'inner_html' => $element->hasChildNodes() ? $this->mapElements($element->childNodes, new ArrayObject()) : new ArrayObject() |
|
181 | 181 | ]; |
182 | 182 | |
183 | 183 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array |
193 | 193 | */ |
194 | - protected function getAttributes( DOMNode $element ) { |
|
194 | + protected function getAttributes(DOMNode $element) { |
|
195 | 195 | |
196 | - if ( !$element->hasAttributes() ) { |
|
196 | + if (!$element->hasAttributes()) { |
|
197 | 197 | return []; |
198 | 198 | } |
199 | 199 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | /** |
203 | 203 | * @var DOMAttr $attr |
204 | 204 | */ |
205 | - foreach ( $element->attributes as $attr ) { |
|
206 | - $attributesMap[ $attr->nodeName ] = $attr->nodeValue; |
|
205 | + foreach ($element->attributes as $attr) { |
|
206 | + $attributesMap[$attr->nodeName] = $attr->nodeValue; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | return $attributesMap; |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | |
219 | 219 | $htmlNodeList = $this->getNodeListFromQueryPath(); |
220 | 220 | |
221 | - if ( !$htmlNodeList instanceof DOMNodeList ) { |
|
222 | - throw new DOMException( 'Bad DOMNodeList' ); |
|
221 | + if (!$htmlNodeList instanceof DOMNodeList) { |
|
222 | + throw new DOMException('Bad DOMNodeList'); |
|
223 | 223 | } |
224 | 224 | |
225 | - if ( $this->isXmlFragment && $htmlNodeList->item( 0 )->nodeName == self::fragmentDocumentRoot ) { |
|
225 | + if ($this->isXmlFragment && $htmlNodeList->item(0)->nodeName == self::fragmentDocumentRoot) { |
|
226 | 226 | // there is a fake root node, skip the first element end start with child nodes |
227 | - $this->mapElements( $htmlNodeList->item( 0 )->childNodes, $this->elements ); |
|
227 | + $this->mapElements($htmlNodeList->item(0)->childNodes, $this->elements); |
|
228 | 228 | } else { |
229 | - $this->mapElements( $htmlNodeList, $this->elements ); |
|
229 | + $this->mapElements($htmlNodeList, $this->elements); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return $this->elements; |
@@ -31,8 +31,8 @@ |
||
31 | 31 | */ |
32 | 32 | protected $XML_OPTIONS = 0; |
33 | 33 | |
34 | - public function __construct( $setRootElement = null, $allowDocumentType = false, $XML_OPTIONS = 0, $schemaOrCallable = null ) { |
|
35 | - $this->XML_OPTIONS = $XML_OPTIONS | ( defined( 'LIBXML_COMPACT' ) ? LIBXML_COMPACT : 0 ); |
|
34 | + public function __construct($setRootElement = null, $allowDocumentType = false, $XML_OPTIONS = 0, $schemaOrCallable = null) { |
|
35 | + $this->XML_OPTIONS = $XML_OPTIONS | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0); |
|
36 | 36 | $this->setRootElement = $setRootElement; |
37 | 37 | $this->allowDocumentType = $allowDocumentType; |
38 | 38 | $this->schemaOrCallable = $schemaOrCallable; |