Skip to content

"Instanceof static" is treated erroneously as "instanceof self" #2231

@kiler129

Description

@kiler129

Bug report

A statement $foo instanceof static is treated like the static is always the same class as the class where statement is placed. This is obviously wrong, and the easiest example will be to imagine an abstract class which does such check.

Code snippet that reproduces the problem

Running example: https://3v4l.org/O87Qc
Analysis: https://phpstan.org/r/d6cb91f9-e428-4652-a8b0-16ee03ff6759

Currently the analysis reports Result of && is always false. for $x !== null && !($x instanceof static) where ?foo $x

Expected output

No error is expected. Psalm recently fixed the same problem: https://psalm.dev/r/4223401cd8

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