Skip to content

Null coalesce operator prevents narrowing the value type #7639

@mvorisek

Description

@mvorisek

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/390bc581-9ff0-4fcf-b195-7e4914cb0fca

Maybe null coalesce operator is expanded internally to the 2nd method in https://phpstan.org/r/a2136bac-6af1-463c-95d9-ebd428fd13cd demo, but that must be understood by phpstan too and such code patterns are commonly used.

Expected output

no phpstan 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