Skip to content

Commit 580d343

Browse files
committed
Fix
1 parent 7073da1 commit 580d343

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/Psalm/Internal/Provider/ReturnTypeProvider/FilterUtils.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Psalm\Type\Atomic\TArray;
2020
use Psalm\Type\Atomic\TArrayKey;
2121
use Psalm\Type\Atomic\TBool;
22+
use Psalm\Type\Atomic\TClosure;
2223
use Psalm\Type\Atomic\TFalse;
2324
use Psalm\Type\Atomic\TFloat;
2425
use Psalm\Type\Atomic\TInt;
@@ -191,7 +192,7 @@ public static function getOptionsArgValueOrError(
191192
if ($filter_int_used === FILTER_CALLBACK) {
192193
$only_callables = true;
193194
foreach ($atomic_type->properties['options']->getAtomicTypes() as $option_atomic) {
194-
if ($option_atomic->isCallableType()) {
195+
if ($option_atomic->isCallableType() && !$option_atomic instanceof TClosure) {
195196
continue;
196197
}
197198

src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static function isContainedBy(
5353
if ($container_type_part instanceof TClosure) {
5454
if ($input_type_part->isCallableType()
5555
&& !$input_type_part instanceof TCallable // it has stricter checks below
56+
&& !$input_type_part instanceof TClosure // it has stricter checks below
5657
) {
5758
if ($atomic_comparison_result) {
5859
$atomic_comparison_result->type_coerced = true;
@@ -62,6 +63,7 @@ public static function isContainedBy(
6263
}
6364
if ($input_type_part->isCallableType()
6465
&& !$input_type_part instanceof TCallable // it has stricter checks below
66+
&& !$input_type_part instanceof TClosure // it has stricter checks below
6567
) {
6668
return true;
6769
}

tests/TypeReconciliation/ReconcilerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function providerTestReconciliation(): array
162162
'nullableClassStringTruthy' => ['class-string<SomeClass>', new Truthy(), 'class-string<SomeClass>|null'],
163163
'iterableToArray' => ['array<int, int>', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'iterable<int, int>'],
164164
'iterableToTraversable' => ['Traversable<int, int>', new IsType(new TNamedObject('Traversable')), 'iterable<int, int>'],
165-
'callableToCallableArray' => ['callable-array{class-string|object, non-empty-string}', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'callable'],
165+
'callableToCallableArray' => ['callable-array{0: class-string|object, 1: non-empty-string}', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'callable'],
166166
'SmallKeyedArrayAndCallable' => ['array{test: string}', new IsType(TKeyedArray::make(['test' => Type::getString()])), 'callable'],
167167
'BigKeyedArrayAndCallable' => ['array{foo: string, test: string, thing: string}', new IsType(TKeyedArray::make(['foo' => Type::getString(), 'test' => Type::getString(), 'thing' => Type::getString()])), 'callable'],
168168
'callableOrArrayToCallableArray' => ['array<array-key, mixed>', new IsType(new TArray([Type::getArrayKey(), Type::getMixed()])), 'callable|array'],

0 commit comments

Comments
 (0)