Skip to content

isset not narrowing down array shapes #8724

@KeironLowe

Description

@KeironLowe

Bug report

Discussion here. If you have an array that could be multiple array shapes, using isset on a key which only exists in one shape doesn't narrow down the array.

Example

https://phpstan.org/r/ee716f2f-3cf4-4b58-ade2-d1375bc60e05 - Since operator only exists within the CombinedNumberFilterStructure shape, I would expect the shape to be narrowed down to NumberFilterStructure for line 21. As mentioned in the discussion, array_key_exists does work.

Expected output

No errors, actual output is Offset 'type' does not exist on array{operator: 'AND'|'OR'}|array{type: 'blank'|'equals'|'greaterThan'|'greaterThanOrEqual'|'inRange'|'lessThan'|'lessThanOrEqual'|'notBlank'|'notEqual'}.

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

Yes, and Ondřej fast responses are always massively appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions