Skip to content

Assert::keyExists() should be supported #39

@clxmstaab

Description

@clxmstaab

with this plugin, phpstan should be aware about the array shape of the variable involved:

/**
 * @param array{password: mixed, email: mixed} $arr
 */
function a($arr) {
}

$data = $_POST;

Assert::keyExists($data, 'password');
Assert::keyExists($data, 'email');

a($data);

it would be even better if we could verify that the keys are of a certain type, e.g. string in my above example.
though it seems this is not even possible with Assert itself, without additional asserts.

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