mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
Merge pull request #10454 from kkmuffme/unsealed-not-nonempty-callable-param-should-be-valid
fix false positive ArgumentTypeCoercion for callback param
This commit is contained in:
commit
1df5b3580b
@ -49,6 +49,19 @@ final class ArrayTypeComparator
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($container_type_part instanceof TKeyedArray
|
||||
&& $input_type_part instanceof TArray
|
||||
&& !$container_type_part->is_list
|
||||
&& !$container_type_part->isNonEmpty()
|
||||
&& !$container_type_part->isSealed()
|
||||
&& $input_type_part->equals(
|
||||
$container_type_part->getGenericArrayType($container_type_part->isNonEmpty()),
|
||||
false,
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($container_type_part instanceof TKeyedArray
|
||||
&& $input_type_part instanceof TArray
|
||||
) {
|
||||
|
@ -1892,6 +1892,22 @@ class CallableTest extends TestCase
|
||||
return [1, 2, 3];
|
||||
});',
|
||||
],
|
||||
'unsealedAllOptionalCbParam' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
* @param callable(array<string, string>) $arg
|
||||
* @return void
|
||||
*/
|
||||
function foo($arg) {}
|
||||
|
||||
/**
|
||||
* @param array{a?: string}&array<string, string> $cb_arg
|
||||
* @return void
|
||||
*/
|
||||
function bar($cb_arg) {}
|
||||
|
||||
foo("bar");',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user