Skip to content

Support looping over array_key_exists with a list of keys #3795

@christeredvartsen

Description

@christeredvartsen

Feature request

See the following for an example: https://phpstan.org/r/4a390276-8f42-45ba-9b3a-b3102a3955c7

Would it be possible to support the more dynamic checking of array_key_exists?

foreach (['foo', 'bar', 'baz'] as $required) {
    if (!array_key_exists($required, $data)) {
        throw new InvalidArgumentException('Missing required attribute: ' . $required);
    }
}

echo $data['foo']; // This line generates an error saying that Offset 'foo' does not exist

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions