@@ -149,7 +149,7 @@ public function testSetNestedElement($class)
149149
150150 $ this ->assertSame ([[['test ' ]]], $ this ->callMethod ([$ class , 'set ' ], [], '[].[].[] ' , 'test ' ));
151151 $ this ->assertSame ([[[[]]]], $ this ->callMethod ([$ class , 'set ' ], [], '[].[].[] ' , []));
152- $ this ->assertSame ([[[[]]]], $ this ->callMethod ([$ class , 'set ' ], [], ['[] ' ,'[] ' ,'[] ' ], []));
152+ $ this ->assertSame ([[[[]]]], $ this ->callMethod ([$ class , 'set ' ], [], ['[] ' , '[] ' , '[] ' ], []));
153153 $ this ->assertSame ([], $ this ->callMethod ([$ class , 'set ' ], [], [], 'test ' ));
154154 $ this ->assertSame ([], $ this ->callMethod ([$ class , 'set ' ], [], [null ], 'test ' ));
155155
@@ -661,8 +661,7 @@ public function testMapObjects($class)
661661 $ this ->assertSame (['test ' , 2 , 4 , '2 ' ], $ this ->callMethod ([$ class , 'mapObjects ' ], $ array , 'test ' , 2 ));
662662 $ this ->assertSame ([], $ this ->callMethod ([$ class , 'mapObjects ' ], [], 'test ' ));
663663
664- $ object = new class ()
665- {
664+ $ object = new class () {
666665 function test ($ arg = 0 )
667666 {
668667 return 1 + $ arg ;
@@ -744,6 +743,35 @@ public function testFilterByKeys($class)
744743 $ this ->assertSame ($ array , $ this ->callMethod ([$ class , 'filterByKeys ' ], $ array , [null , 0 ], true ));
745744 }
746745
746+ /**
747+ * @param $class string|ArrObj
748+ *
749+ * @dataProvider arrayClassProvider
750+ */
751+ public function testFilter ($ class )
752+ {
753+ $ callback1 = function ($ value ) {
754+ return boolval ($ value );
755+ };
756+ $ callback2 = function ($ value ) {
757+ return !$ value ;
758+ };
759+ $ callback3 = function ($ value , $ key ) {
760+ return $ key == $ value ;
761+ };
762+ $ callback4 = function ($ key ) {
763+ return boolval ($ key );
764+ };
765+
766+ foreach ($ this ->arrayProvider () as [$ array ]) {
767+ $ this ->assertSame (array_filter ($ array ), $ this ->callMethod ([$ class , 'filter ' ], $ array ));
768+ $ this ->assertSame (array_filter ($ array , $ callback1 ), $ this ->callMethod ([$ class , 'filter ' ], $ array , $ callback1 ));
769+ $ this ->assertSame (array_filter ($ array , $ callback2 ), $ this ->callMethod ([$ class , 'filter ' ], $ array , $ callback2 ));
770+ $ this ->assertSame (array_filter ($ array , $ callback3 , ARRAY_FILTER_USE_BOTH ), $ this ->callMethod ([$ class , 'filter ' ], $ array , $ callback3 , ARRAY_FILTER_USE_BOTH ));
771+ $ this ->assertSame (array_filter ($ array , $ callback4 , ARRAY_FILTER_USE_KEY ), $ this ->callMethod ([$ class , 'filter ' ], $ array , $ callback4 , ARRAY_FILTER_USE_KEY ));
772+ }
773+ }
774+
747775 /**
748776 * @param $class string|ArrObj
749777 *
@@ -1019,7 +1047,8 @@ public function testSortObjects($class)
10191047 $ object1 = new class () {
10201048 public $ i = 1 ;
10211049
1022- public function getValue (bool $ reverse = false ) {
1050+ public function getValue (bool $ reverse = false )
1051+ {
10231052 return $ reverse ? 1 / $ this ->i : $ this ->i ;
10241053 }
10251054 };
@@ -1039,7 +1068,7 @@ public function getValue(bool $reverse = false) {
10391068 $ array = $ proto ;
10401069
10411070 $ this ->assertSame ([1 , 2 , 3 , 4 , 5 ], $ this ->callMethod ([$ class , 'mapObjects ' ], $ array , 'getValue ' ));
1042- $ this ->assertSame ([1 , 1 / 2 , 1 / 3 , 1 / 4 , 1 / 5 ], $ this ->callMethod ([$ class , 'mapObjects ' ], $ array , 'getValue ' , true ));
1071+ $ this ->assertSame ([1 , 1 / 2 , 1 / 3 , 1 / 4 , 1 / 5 ], $ this ->callMethod ([$ class , 'mapObjects ' ], $ array , 'getValue ' , true ));
10431072
10441073 // Ensure order is not the same
10451074 do {
@@ -1465,8 +1494,7 @@ public function testClone($class)
14651494 {
14661495 $ object = new stdClass ();
14671496 $ object2 = new ArrayObject ();
1468- $ object3 = new class ()
1469- {
1497+ $ object3 = new class () {
14701498 public $ counter = 1 ;
14711499
14721500 function __clone ()
0 commit comments