Skip to content

Null coalesce assignment to an array with optional key doesn't work #3276

@Daeroni

Description

@Daeroni

Bug report

If an array has been documented with an optional key, and then a null coalesce assignment is used to make sure the key exists, PHPStan doesn't realise that the key always exists in the array after the assignment.

Code snippet that reproduces the problem

https://phpstan.org/r/91be56c3-ab29-44e8-a2d3-059d3a7f9652

Expected output

No errors

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