Skip to content

False positive: array_chunk with treatPhpDocTypesAsCertain: false element comparison will always evaluate to false #8956

@schlndh

Description

@schlndh

Bug report

It seems that PHPStan 1.10 gets confused about the shape of array_chunk result when treatPhpDocTypesAsCertain: false is set.

Code snippet that reproduces the problem

https://phpstan.org/r/1bd0816f-6c2e-4979-910c-a6afcf50b9f2

Note that if I add \PHPStan\dumpType($val) before the if it reports the correct element type (in this case 0-10), but it still complains about the condition being false.

If I turn treatPhpDocTypesAsCertain back on the problem disappears as well. Which is a bit weird considering that there are no phpdocs in the code sample.

Expected output

No issue should be reported regardless of treatPhpDocTypesAsCertain.

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