Skip to content

instanceof type information is not propagated with assignments #3024

@jbafford

Description

@jbafford

Bug report

phpstan does not correctly propagate type information if an assignment is involved in an instanceof test.

Code snippet that reproduces the problem

https://phpstan.org/r/63411238-7893-4c6e-b6ff-16b1f1f78700

Expected output

foo() correctly reports no errors, but has redundantly do the comparison $elt instanceof A. bar() and baz() report attempting to call an undefined method on A|U::getUser(), on a line that can only be executed if $elt instanceof A (which implements the method).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions