File tree Expand file tree Collapse file tree
src/SbWereWolf/XmlNavigator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,18 +191,11 @@ private static function createXmlReader(
191191 $ reader = new XMLReader ();
192192
193193 if ($ xmlText !== '' ) {
194- $ loaded = @$ reader ->XML (
194+ @$ reader ->XML (
195195 $ xmlText ,
196196 $ encoding ,
197197 $ flags
198198 );
199- if ($ loaded !== true ) {
200- throw new InvalidArgumentException (
201- 'Unable to parse XML from $xmlText. ' .
202- self ::formatLibxmlErrors (),
203- -669
204- );
205- }
206199
207200 return $ reader ;
208201 }
Original file line number Diff line number Diff line change @@ -117,10 +117,11 @@ private static function composeElement(
117117 continue ;
118118 }
119119
120- if ($ reader ->nodeType === XMLReader::END_ELEMENT ) {
121- if ($ reader ->depth === $ startDepth ) {
122- break ;
123- }
120+ if (
121+ $ reader ->nodeType === XMLReader::END_ELEMENT
122+ && $ reader ->depth === $ startDepth
123+ ) {
124+ break ;
124125 }
125126 }
126127
Original file line number Diff line number Diff line change @@ -144,10 +144,11 @@ private static function composeElement(
144144 continue ;
145145 }
146146
147- if ($ reader ->nodeType === XMLReader::END_ELEMENT ) {
148- if ($ reader ->depth === $ startDepth ) {
149- break ;
150- }
147+ if (
148+ $ reader ->nodeType === XMLReader::END_ELEMENT
149+ && $ reader ->depth === $ startDepth
150+ ) {
151+ break ;
151152 }
152153 }
153154
Original file line number Diff line number Diff line change 44namespace SbWereWolf \XmlNavigator \Test \Unit \Extraction ;
55
66use PHPUnit \Framework \TestCase ;
7+ use ReflectionMethod ;
78use SbWereWolf \XmlNavigator \Extraction \PrettyPrintComposer ;
89use SbWereWolf \XmlNavigator \Test \Support \XmlFixture ;
910
@@ -153,4 +154,16 @@ public function testComposeTurnsRepeatedChildTagsIntoList()
153154
154155 $ reader ->close ();
155156 }
157+
158+ public function testFirstKeyReturnsNullForEmptyArray ()
159+ {
160+ $ method = new ReflectionMethod (
161+ PrettyPrintComposer::class,
162+ 'firstKey '
163+ );
164+ /** @noinspection PhpExpressionResultUnusedInspection */
165+ $ method ->setAccessible (true );
166+
167+ self ::assertNull ($ method ->invoke (null , []));
168+ }
156169}
You can’t perform that action at this time.
0 commit comments