@@ -337,19 +337,21 @@ public function testQueryMatchEqualsWithUnquotedInteger(): void
337337 */
338338 public function testQueryMatchNotEqualsTo (): void
339339 {
340- $ results = (new JSONPath ($ this ->getData ('example ' )))
340+ $ jsonPath = (new JSONPath ($ this ->getData ('example ' )));
341+
342+ $ results = $ jsonPath
341343 ->find ('$..books[?(@.author != "J. R. R. Tolkien")].title ' );
342344
343345 self ::assertcount (3 , $ results );
344346 self ::assertEquals (['Sayings of the Century ' , 'Sword of Honour ' , 'Moby Dick ' ], $ results ->getData ());
345347
346- $ results = ( new JSONPath ( $ this -> getData ( ' example ' )))
348+ $ results = $ jsonPath
347349 ->find ('$..books[?(@.author !== "J. R. R. Tolkien")].title ' );
348350
349351 self ::assertcount (3 , $ results );
350352 self ::assertEquals (['Sayings of the Century ' , 'Sword of Honour ' , 'Moby Dick ' ], $ results ->getData ());
351353
352- $ results = ( new JSONPath ( $ this -> getData ( ' example ' )))
354+ $ results = $ jsonPath
353355 ->find ('$..books[?(@.author <> "J. R. R. Tolkien")].title ' );
354356
355357 self ::assertcount (3 , $ results );
@@ -364,17 +366,19 @@ public function testQueryMatchNotEqualsTo(): void
364366 */
365367 public function testQueryMatchWithRegexCaseSensitive (): void
366368 {
367- $ result = (new JSONPath ($ this ->getData ('example ' )))
369+ $ jsonPath = (new JSONPath ($ this ->getData ('example ' )));
370+
371+ $ results = $ jsonPath
368372 ->find ('$..books[?(@.author =~ /nigel ree?s/i)].title ' );
369373
370- self ::assertcount (1 , $ result );
371- self ::assertEquals (['Sayings of the Century ' ], $ result ->getData ());
374+ self ::assertcount (1 , $ results );
375+ self ::assertEquals (['Sayings of the Century ' ], $ results ->getData ());
372376
373- $ result = ( new JSONPath ( $ this -> getData ( ' example ' )))
377+ $ results = $ jsonPath
374378 ->find ('$..books[?(@.title =~ /^(Say|The).*/)].title ' );
375379
376- self ::assertcount (2 , $ result );
377- self ::assertEquals (['Sayings of the Century ' , 'The Lord of the Rings ' ], $ result ->getData ());
380+ self ::assertcount (2 , $ results );
381+ self ::assertEquals (['Sayings of the Century ' , 'The Lord of the Rings ' ], $ results ->getData ());
378382 }
379383
380384 /**
@@ -602,8 +606,7 @@ public function testSimpleArrayAccess(): void
602606 */
603607 public function testFilteringOnNoneArrays (): void
604608 {
605- $ data = ['foo ' => 'asdf ' ];
606- $ result = (new JSONPath ($ data ))
609+ $ result = (new JSONPath (['foo ' => 'asdf ' ]))
607610 ->find ('$.foo.bar ' );
608611
609612 self ::assertEquals ([], $ result ->getData ());
@@ -636,8 +639,7 @@ public function testMatchWithComplexSquareBrackets(): void
636639 */
637640 public function testQueryMatchWithRecursive (): void
638641 {
639- $ locations = $ this ->getData ('locations ' );
640- $ result = (new JSONPath ($ locations ))
642+ $ result = (new JSONPath ($ this ->getData ('locations ' )))
641643 ->find ("..[?(@.type == 'suburb')].name " );
642644
643645 self ::assertEquals (["Rosebank " ], $ result ->getData ());
@@ -681,12 +683,14 @@ public function testSlashesInIndex(): void
681683 */
682684 public function testCyrillicText (): void
683685 {
684- $ result = (new JSONPath (["трололо " => 1 ]))
686+ $ jsonPath = (new JSONPath (["трололо " => 1 ]));
687+
688+ $ result = $ jsonPath
685689 ->find ("$['трололо'] " );
686690
687691 self ::assertEquals ([1 ], $ result ->getData ());
688692
689- $ result = ( new JSONPath ([ " трололо " => 1 ]))
693+ $ result = $ jsonPath
690694 ->find ("$.трололо " );
691695
692696 self ::assertEquals ([1 ], $ result ->getData ());
@@ -697,14 +701,19 @@ public function testCyrillicText(): void
697701 */
698702 public function testOffsetUnset (): void
699703 {
700- $ data = [
701- "route " => [
702- ["name " => "A " , "type " => "type of A " ],
703- ["name " => "B " , "type " => "type of B " ],
704- ],
705- ];
706- $ data = json_encode ($ data );
707- $ jsonIterator = new JSONPath (json_decode ($ data , false ));
704+ $ jsonIterator = new JSONPath (
705+ json_decode (
706+ json_encode (
707+ [
708+ "route " => [
709+ ["name " => "A " , "type " => "type of A " ],
710+ ["name " => "B " , "type " => "type of B " ],
711+ ],
712+ ]
713+ ),
714+ false
715+ )
716+ );
708717
709718 /** @var JSONPath $route */
710719 $ route = $ jsonIterator ->offsetGet ('route ' );
0 commit comments