-
-
Couldn't load subscription status.
- Fork 933
Open
phpstan/phpstan-src
#4472Description
Bug report
When an instanceof check is used on a variable typed as object, PHPStan incorrectly infers its type as the concrete class (T) instead of the correct intersection type (object&T). This leads to a false-positive with a subsequent is_subclass_of() check since PHPStan believes that the same type is being supplied to its first and second parameters.
Consult the linked test snippet for more detail about the erroneous pattern.
Code snippet that reproduces the problem
https://phpstan.org/r/25c06554-9cd6-42ea-bd30-d86dc12d94b6
Expected output
Line Error
6
Dumped type: object
Non-ignorable
8
Dumped type: object&stdClass
Non-ignorable
Did PHPStan help you today? Did it make you happy in any way?
No response
Metadata
Metadata
Assignees
Labels
No labels