1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Prevent type coercion from get_class output

This commit is contained in:
Brown 2018-11-26 16:39:59 -05:00
parent af041abdcb
commit 97c0a94b42

View File

@ -15,6 +15,7 @@ use Psalm\Type\Atomic\TFalse;
use Psalm\Type\Atomic\TFloat;
use Psalm\Type\Atomic\TGenericObject;
use Psalm\Type\Atomic\TGenericParam;
use Psalm\Type\Atomic\GetClassT;
use Psalm\Type\Atomic\THtmlEscapedString;
use Psalm\Type\Atomic\TInt;
use Psalm\Type\Atomic\TLiteralClassString;
@ -699,14 +700,19 @@ class TypeAnalyzer
);
}
if (($input_type_part instanceof TClassString || $input_type_part instanceof TLiteralClassString)
if (($input_type_part instanceof TClassString
|| $input_type_part instanceof TLiteralClassString)
&& (get_class($container_type_part) === TString::class
|| get_class($container_type_part) === TSingleLetter::class
|| get_class($container_type_part) === Type\Atomic\GetClassT::class)
|| get_class($container_type_part) === GetClassT::class)
) {
return true;
}
if ($container_type_part instanceof TClassString && $input_type_part instanceof GetClassT) {
return true;
}
if ($container_type_part instanceof TString
&& ($input_type_part instanceof TNumericString
|| $input_type_part instanceof THtmlEscapedString)