Skip to content

Refinement of key existence is wrong when using a AND in a condition #7224

@stof

Description

@stof

Bug report

When using if (!isset($a['first_key']) && !isset($a['second_key'])) return;, phpstan refines first_key as not being optional in the array shape of $a after the early return

Code snippet that reproduces the problem

https://phpstan.org/r/292eadfe-27e6-4668-b7e5-ccc91c581290

Expected output

The array_key_exists call is not reported as useless by strict rules, because team_name can indeed be missing when reaching it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions