Skip to content

is_* with null coalesce on array value does not reduce the type #5304

@BackEndTea

Description

@BackEndTea

Bug report

When doing an is_string check on an array access, within an if with a null coalesce (in case the key is not present), does not make PHPStan understand that they key must be there.

Code snippet that reproduces the problem

https://phpstan.org/r/d3ff8430-a6ae-498a-b09e-fed774f9099d

Expected output

I expected both outputs to be Dumped type: array('foo' => string)

I know this isn't the best code, and an isset would've been better here, but i noticed this in our code base.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions