mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Prioritize TCallableString handling to avoid simpler checks for TLowercaseString vs TString (#5811)
This commit is contained in:
parent
4b17cc9a4b
commit
4d6be66d98
@ -13,6 +13,7 @@ use Psalm\Type\Atomic\TClassString;
|
||||
use Psalm\Type\Atomic\TCallableString;
|
||||
use Psalm\Type\Atomic\TFalse;
|
||||
use Psalm\Type\Atomic\TFloat;
|
||||
use Psalm\Type\Atomic\TLowercaseString;
|
||||
use Psalm\Type\Atomic\TTemplateParam;
|
||||
use Psalm\Type\Atomic\TTemplateParamClass;
|
||||
use Psalm\Type\Atomic\TDependentGetClass;
|
||||
@ -70,6 +71,16 @@ class ScalarTypeComparator
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($input_type_part instanceof TCallableString
|
||||
&& (get_class($container_type_part) === TString::class
|
||||
|| get_class($container_type_part) === TSingleLetter::class
|
||||
|| get_class($container_type_part) === TNonEmptyString::class
|
||||
|| get_class($container_type_part) === TNonFalsyString::class
|
||||
|| get_class($container_type_part) === TLowercaseString::class)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (($container_type_part instanceof Type\Atomic\TLowercaseString
|
||||
|| $container_type_part instanceof Type\Atomic\TNonEmptyLowercaseString)
|
||||
&& $input_type_part instanceof TString
|
||||
@ -417,15 +428,6 @@ class ScalarTypeComparator
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($input_type_part instanceof TCallableString
|
||||
&& (get_class($container_type_part) === TString::class
|
||||
|| get_class($container_type_part) === TSingleLetter::class
|
||||
|| get_class($container_type_part) === TNonEmptyString::class
|
||||
|| get_class($container_type_part) === TNonFalsyString::class)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($input_type_part instanceof TNumericString
|
||||
&& get_class($container_type_part) === TNonEmptyString::class
|
||||
) {
|
||||
|
@ -116,6 +116,10 @@ class TypeComparatorTest extends TestCase
|
||||
'array{foo?: string}&array<string, mixed>',
|
||||
'array<empty, empty>',
|
||||
],
|
||||
'Lowercase-stringAndCallable-string' => [
|
||||
'lowercase-string',
|
||||
'callable-string',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user