Skip to content

False positive when comparing two variables to null and using the other #4326

@gnutix

Description

@gnutix

Bug report

If you have two nullable variables, and you first check that both are null (and if so break/return/throw), then check if one is null and use the other, it should report that the "other" can be null.

Code snippet that reproduces the problem

With return : https://phpstan.org/r/a3327010-6db9-4d2e-bb4a-0ff19378de1d
With throw : https://phpstan.org/r/3eb7a19d-7fc1-49e9-8cde-411d06b1fd3d

Expected output

There should be no errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions