Thanks to visit codestin.com
Credit goes to github.com

Skip to content

List is wrongly inferred as non empty #10085

@Griffon-Weglot

Description

@Griffon-Weglot

Bug report

In the following example
https://phpstan.org/r/3ac09ec1-e62e-42b0-b853-06a1450c238f

The array $foo is considered as non empty but shouldn't.
If I pass [], [] to the method, the final array is empty.

As soon as I change the typehint from list to array, the array is correctly inferred as array (and not non-empty-array)
https://phpstan.org/r/1b3c3201-730a-488e-988d-8e7ec87bad30

Code snippet that reproduces the problem

https://phpstan.org/r/3ac09ec1-e62e-42b0-b853-06a1450c238f

Expected output

No error

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
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions