1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Catch string subtypes that cannot be identical

This commit is contained in:
Brown 2020-07-14 10:08:31 -04:00
parent 2399643472
commit f0a5463834
2 changed files with 11 additions and 1 deletions

View File

@ -1010,7 +1010,10 @@ class AssertionFinder
if ($codebase
&& $other_type
&& $var_type
&& $conditional instanceof PhpParser\Node\Expr\BinaryOp\Identical
&& ($conditional instanceof PhpParser\Node\Expr\BinaryOp\Identical
|| ($other_type->isString()
&& $var_type->isString())
)
) {
$parent_source = $source->getSource();

View File

@ -3202,6 +3202,13 @@ class ConditionalTest extends \Psalm\Tests\TestCase
}',
'error_message' => 'ArgumentTypeCoercion',
],
'getClassCannotBeStringEquals' => [
'<?php
function foo(Exception $e) : void {
if (get_class($e) == "InvalidArgumentException") {}
}',
'error_message' => 'TypeDoesNotContainType',
],
];
}
}