Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stored result of instanceof is consumed after the first check #14545

@GottemHams

Description

@GottemHams

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions