-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Description
Bug report
After updating to PHPStan 2.1.32, or with instanceof check cause invalid result for:
class SomeClass implements Stringable
{
#[Override]
public function __toString(): string
{
return 'test';
}
}
$data = rand(0, 1) ?
'test'
: new SomeClass;
if ((is_string($data) || $data instanceof SomeClass) && preg_match('/test/', (string) $data)) {
}It shows
Instanceof between SomeClass and SomeClass will always evaluate to true.
Result of || is always true.
see https://phpstan.org/r/65540846-1bed-4ca6-80e8-038aba2ea92e
Code snippet that reproduces the problem
https://phpstan.org/r/65540846-1bed-4ca6-80e8-038aba2ea92e
Expected output
It should not show a phpstan notice.
see result https://3v4l.org/tK1i2
Did PHPStan help you today? Did it make you happy in any way?
No response
Metadata
Metadata
Assignees
Labels
No labels