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:
parent
2399643472
commit
f0a5463834
@ -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();
|
||||
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user