Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed May 3, 2024
1 parent 0bc6969 commit 3b512ce
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
use Psalm\Type\Union;
use UnexpectedValueException;

use function array_filter;
use function count;
use function explode;
use function implode;
Expand Down Expand Up @@ -955,12 +956,13 @@ public static function verifyType(
) {
$potential_method_ids = [];

$param_type_without_callable = new Union(array_filter(
$param_types_without_callable = array_filter(
$param_type->getAtomicTypes(),
static function (Atomic $atomic) {
return !$atomic instanceof Atomic\TCallableInterface;
})
static fn(Atomic $atomic) => !$atomic instanceof Atomic\TCallableInterface,
);
$param_type_without_callable = [] !== $param_types_without_callable
? new Union($param_types_without_callable)
: null;

foreach ($input_type->getAtomicTypes() as $input_type_part) {
if ($input_type_part instanceof TList) {
Expand All @@ -969,7 +971,7 @@ static function (Atomic $atomic) {

if ($input_type_part instanceof TKeyedArray) {
// If the param accept an array, we don't report arrays as wrong callbacks.
if (UnionTypeComparator::isContainedBy(
if (null !== $param_type_without_callable && UnionTypeComparator::isContainedBy(
$codebase,
$input_type,
$param_type_without_callable,
Expand Down

0 comments on commit 3b512ce

Please sign in to comment.