Skip to content

False positive "Variable might not be defined" with array_key_exists and isset #13694

@theodorejb

Description

@theodorejb

Bug report

Starting in PHPStan 2.1.30, there is a "Variable might not be defined" error when using array_key_exists in a loop, followed by an isset check for an offset of the array. But the variable is always defined, and there was no error in PHPStan 2.1.29.

Code snippet that reproduces the problem

https://phpstan.org/r/9036d9ce-df31-42d1-81d3-c1deadf4c3d7

Expected output

No error

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

No response

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