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

Skip to content

PHP8: call_user_func_array can break because of named parameters #5934

@mglaman

Description

@mglaman

Feature request

Split from #5368

Example: https://3v4l.org/A2MGD

var_dump(call_user_func_array('array_merge', ['foo' => ['bar' => 2]]));
Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in /in/A2MGD:3
Stack trace:
#0 /in/A2MGD(3): array_merge(foo: Array)
#1 {main}

We need rules for call_user_func and call_user_func_array and the functions/methods they call.

Playground example: https://phpstan.org/r/89ee6acd-0ba3-4712-b509-10eb43789518

PHPStan actually reports the array with named arguments as invalid.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions