Skip to content

Coalesce operator with array access on mixed #7073

Description

@enumag

Bug report

I'm not completely sure if this is bug or intended behavior but long story short I wanted a simple code to get a particular field from a json response and throw exception if it wasn't there or had unexpected type. I'd like to avoid needless complications to the code just to satisfy phpstan.

Code snippet that reproduces the problem

https://phpstan.org/r/f66c7736-6cc6-48a3-8a50-6bfdde596384

Expected output

I'd expect no errors since the ?? operator handles the case when the variable isn't an array. See https://3v4l.org/qEje7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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