Skip to content

Commit 11cee5a

Browse files
greg0iresebastianbergmann
authored andcommitted
Allow named arguments with InvocationStubber::with()
with() uses a unique, variadic parameter, and there should be no static analysis issue when calling it with named arguments, because those will not refer to the parameters of that method, but to the parameters of the method specified when calling method(). Fixes #6163
1 parent c11cd7c commit 11cee5a

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/Framework/MockObject/Runtime/Interface/InvocationStubber.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,29 @@
1414
use PHPUnit\Framework\MockObject\Stub\Stub;
1515
use Throwable;
1616

17-
/**
18-
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
19-
*/
2017
interface InvocationStubber
2118
{
2219
/**
20+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
21+
*
2322
* @param Constraint|non-empty-string|PropertyHook $constraint
2423
*
2524
* @return $this
2625
*/
2726
public function method(Constraint|PropertyHook|string $constraint): self;
2827

2928
/**
29+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
30+
*
3031
* @param non-empty-string $id
3132
*
3233
* @return $this
3334
*/
3435
public function id(string $id): self;
3536

3637
/**
38+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
39+
*
3740
* @param non-empty-string $id
3841
*
3942
* @return $this
@@ -46,53 +49,73 @@ public function after(string $id): self;
4649
public function with(mixed ...$arguments): self;
4750

4851
/**
52+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
53+
*
4954
* @return $this
5055
*/
5156
public function withAnyParameters(): self;
5257

5358
/**
59+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
60+
*
5461
* @return $this
5562
*/
5663
public function will(Stub $stub): self;
5764

5865
/**
66+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
67+
*
5968
* @return $this
6069
*/
6170
public function willReturn(mixed $value, mixed ...$nextValues): self;
6271

6372
/**
73+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
74+
*
6475
* @return $this
6576
*/
6677
public function willReturnReference(mixed &$reference): self;
6778

6879
/**
80+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
81+
*
6982
* @param array<int, array<int, mixed>> $valueMap
7083
*
7184
* @return $this
7285
*/
7386
public function willReturnMap(array $valueMap): self;
7487

7588
/**
89+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
90+
*
7691
* @return $this
7792
*/
7893
public function willReturnArgument(int $argumentIndex): self;
7994

8095
/**
96+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
97+
*
8198
* @return $this
8299
*/
83100
public function willReturnCallback(callable $callback): self;
84101

85102
/**
103+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
104+
*
86105
* @return $this
87106
*/
88107
public function willReturnSelf(): self;
89108

90109
/**
110+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
111+
*
91112
* @return $this
92113
*/
93114
public function willReturnOnConsecutiveCalls(mixed ...$values): self;
94115

95116
/**
117+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
118+
*
96119
* @return $this
97120
*/
98121
public function willThrowException(Throwable $exception): self;

0 commit comments

Comments
 (0)