Skip to content

Commit

Permalink
Fix "Call to function array_filter() requires parameter #2 to be passed"
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Apr 6, 2024
1 parent c1739d0 commit 1bc5cef
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Type/WebMozartAssert/AssertTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\ArrayItem;
use PhpParser\Node\Expr\BinaryOp;
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
Expand Down Expand Up @@ -49,9 +48,7 @@
use PHPStan\Type\TypeCombinator;
use ReflectionObject;
use Traversable;
use function array_filter;
use function array_key_exists;
use function array_map;
use function array_reduce;
use function array_shift;
use function count;
Expand Down Expand Up @@ -966,13 +963,19 @@ private static function buildAnyOfExpr(Scope $scope, Arg $value, Arg $items, cal
return null;
}

$resolvers = array_map(
static function (?ArrayItem $item) use ($scope, $value, $resolver) {
return $item !== null ? $resolver($scope, $value, new Arg($item->value)) : null;
},
$items->value->items
);
$resolvers = array_filter($resolvers);
$resolvers = [];
foreach ($items->value->items as $key => $item) {
if ($item === null) {
continue;
}

$resolved = $resolver($scope, $value, new Arg($item->value));
if ($resolved === null) {
continue;
}

$resolvers[$key] = $resolved;
}

return self::implodeExpr($resolvers, BooleanOr::class);
}
Expand Down

0 comments on commit 1bc5cef

Please sign in to comment.