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 43162de
Showing 1 changed file with 10 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,16 @@ 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(array_filter(

Check failure on line 964 in src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php

View workflow job for this annotation

GitHub Actions / build

ArgumentTypeCoercion

src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php:964:29: ArgumentTypeCoercion: Argument 1 of Psalm\Type\Union::__construct expects non-empty-array<array-key, Psalm\Type\Atomic>, but parent type array<string, Psalm\Type\Atomic> provided (see https://psalm.dev/193)
$param_type->getAtomicTypes(),
static fn (Atomic $atomic) => !$atomic instanceof Atomic\TCallableInterface
))
: null;

foreach ($input_type->getAtomicTypes() as $input_type_part) {
if ($input_type_part instanceof TList) {
Expand All @@ -969,7 +974,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 43162de

Please sign in to comment.