Skip to content

array_combine throws ValueError false positive #13642

@VincentLanglet

Description

@VincentLanglet

Bug report

Since https://github.com/JetBrains/phpstorm-stubs/pull/1783/files, PHPStan now thinks array_combine throws a valueError even if it never does. (For instance https://phpstan.org/r/878b99ee-9004-430c-aea1-b706382196aa)

It could be useful to add a ArrayCombineFunctionThrowTypeExtension to reduce the false positive.
It would be similar to (and might use) ArrayCombineFunctionReturnTypeExtension.

It could also be great to support

array_combine(array_column($a, 'a'), array_column($a, 'b'))

but that's another topics.

Code snippet that reproduces the problem

https://phpstan.org/r/878b99ee-9004-430c-aea1-b706382196aa

Expected output

No errors

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

No response

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