Skip to content

Commit 4a6d59a

Browse files
committed
Added PHP 7.x compatibility for filter() again
1 parent 65feae0 commit 4a6d59a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Map.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,12 @@ public function except( $keys ) : self
15261526
*/
15271527
public function filter( ?callable $callback = null ) : self
15281528
{
1529-
return new static( array_filter( $this->list(), $callback, ARRAY_FILTER_USE_BOTH ) );
1529+
// PHP 7.x compatibility
1530+
if( $callback ) {
1531+
return new static( array_filter( $this->list(), $callback, ARRAY_FILTER_USE_BOTH ) );
1532+
}
1533+
1534+
return new static( array_filter( $this->list() ) );
15301535
}
15311536

15321537

0 commit comments

Comments
 (0)