Skip to content

Accesing private properties with null coalsce isn't reported #12645

@BackEndTea

Description

@BackEndTea

Bug report

Doing a null coalesce while accessing a private property is not reported.

During run time this won't give an error, but the coalesce statement could basically be replaced by the right hand side.

This should probably be reported as a useless coalesce.

Code snippet that reproduces the problem

https://phpstan.org/r/1f251a28-0ae2-4b6e-a5c1-5e77b64b0b4d

Expected output

Error on both line 15 and 16

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions