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.
Bug report
Discussion here. If you have an array that could be multiple array shapes, using
isseton 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
operatoronly exists within theCombinedNumberFilterStructureshape, I would expect the shape to be narrowed down toNumberFilterStructurefor line 21. As mentioned in the discussion,array_key_existsdoes 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.