Open
Description
Q | A |
---|---|
PHPUnit version | at least version 9 |
Summary
The InvocationMocker
class is annotated with @no-named-arguments
- as this is on a class-level, it also affects the with()
function, that only has a single variadic argument. This leads to static analysis issues.
Current behavior
When using PHPStan in a project where with()
is used with an array (not a list), this may lead to a static analysis error (although the keys are ignored anyways):
Method […]\InvocationMocker::willReturn() invoked with unpacked array with possibly string key, but it's not allowed because of @no-named-arguments.
How to reproduce
$input = ['a' => 'foo', 'b' => 'bar'];
$mock->with(...$input); // invalid
$mock->with(...array_values($input)); // valid
$mock->willReturn(/* … */);
Expected behavior
Both cases are a valid usage, so I'd expect there would be no static analysis errors.