Skip to content

Memoization property on class now incorrectly treated as always null after set #12946

@donatj

Description

@donatj

Bug report

We have a nullable property used for memoization on a simple wrapper class.

PHPStan now incorrectly believes the property is always null.

Testing versions, PHPStan 2.1.12 seemed to be OK, but the problem arose with 2.1.13

Code snippet that reproduces the problem

https://phpstan.org/r/3e3e91c9-82f6-45b5-8a97-7beb70586772

Expected output

No Error

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

Helps me every day. Makes it so I can take a day off and not worry about PR's I'm not there to review breaking our 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