Skip to content

PHPStan does not honour nullsafe operator short circuiting #4199

@jiripudil

Description

@jiripudil

Bug report

The nullsafe operator (?->) short-circuits if the left operand is null, i.e. the rest of the chain is not evaluated. However, PHPStan seems to report "might be null" errors on the subsequent expressions.

Code snippet that reproduces the problem

https://phpstan.org/r/ef1aa26d-079b-4032-8e0a-f6b50fd3e5cb

Expected output

No error, it's valid code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions