Skip to content

incorrect type narrowing of array key's value #12067

@vdauchy

Description

@vdauchy

Bug report

After:

\is_string($tag['name'] ?? throw new \Exception()) 
    ? $tag['name'] 
    : throw new \Exception()
;

The value of $tag['name'] is still considered as mixed.

Note that this appears on levels 9 and 10 but not on 8 or lower.

Might have some relation to #12057

Code snippet that reproduces the problem

https://phpstan.org/r/962cb427-a1c7-4ad8-bc18-eb7abb84f7b0

Expected output

The value of $tag['name'] shall be concidered as existing and of string type.

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

Yes, thank you :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions