Bug report
Per #9519:
When the result of an instanceof check is stored in a variable, the result is "consumed" after the first check. I think it might have something to do with generics, as a function just returning any plain old object doesn't result in this problem.
Code snippet that reproduces the problem
https://phpstan.org/r/30fd283a-b43d-4999-871e-4442f4e37e4a
Expected output
The type of $obj inside the second if($is_interface) should still be ObjectClass & SomeInterface.
Did PHPStan help you today? Did it make you happy in any way?
No response
Bug report
Per #9519:
When the result of an
instanceofcheck is stored in a variable, the result is "consumed" after the first check. I think it might have something to do with generics, as a function just returning any plain oldobjectdoesn't result in this problem.Code snippet that reproduces the problem
https://phpstan.org/r/30fd283a-b43d-4999-871e-4442f4e37e4a
Expected output
The type of
$objinside the secondif($is_interface)should still beObjectClass & SomeInterface.Did PHPStan help you today? Did it make you happy in any way?
No response