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

Skip to content

in_array check on an array with optional keys seems buggy #8864

@VincentLanglet

Description

@VincentLanglet

Bug report

While working on phpstan/phpstan-src#2230, I discovered another issue with in_array type specifier.

Code snippet that reproduces the problem

https://phpstan.org/r/3e01e64c-0c75-4944-adb4-1f16c8c3418f

Expected output

I'm not sure what PHPStan would be able to do.
Narrowing the array array{0: 1, 1?: 2} with an in_array(2, check would be great. But we have to care about doing this like array{0: 1, 1?: 2, 2?: 2}

But at least the last error Expected type 2, actual: *NEVER* seems to be a bug to me.

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