Skip to content

False positive "Offset 'foo' on array{...} in isset() always exists and is not nullable." #10025

@gharlan

Description

@gharlan

Bug report

After the first loop, the foo offset exists in each array group element. But after the second loop, there can be group elements without foo offset.

Code snippet that reproduces the problem

https://phpstan.org/r/e89421d7-32a7-45e8-86dd-24f601acd0a8

Expected output

There should be no error.

For the dumped type the expected output is:

-Dumped type: array<int, array{bar?: non-empty-array<int<0, max>, MyClass>, foo: non-empty-array<int<0, max>, MyClass>}>
+Dumped type: array<int, array{bar?: non-empty-array<int<0, max>, MyClass>, foo?: non-empty-array<int<0, max>, MyClass>}>

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions