Skip to content

Null coalesce assignment is not detected as read if the value of the statement is used #3636

@Daeroni

Description

@Daeroni

Bug report

Using 0.12.33 bleeding edge, when doing an null coalesce assignment to a private property and the value is used, eg in a return statement (eg. as part of memoization) phpstan does not detect the assignment as a read and marks the property as never read (if there are no other reads).

This also happens with normal assignment, but I think that does not really matter as it is not really reading the property.

Code snippet that reproduces the problem

Null coalesce assignment https://phpstan.org/r/93468091-cf95-469f-88d8-09029b9daf4a

(Normal assignment https://phpstan.org/r/69126c69-30b5-4549-b57e-a29defb0caf9 )

Expected output

No error

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