Skip to content

Commit a971e22

Browse files
Merge branch '12.0'
2 parents 874f0d4 + fb4df53 commit a971e22

File tree

11 files changed

+59
-152
lines changed

11 files changed

+59
-152
lines changed

src/Framework/MockObject/Runtime/Api/Method.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace PHPUnit\Framework\MockObject;
1111

1212
use PHPUnit\Framework\Constraint\Constraint;
13-
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
1413
use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount;
1514
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;
1615

@@ -23,7 +22,7 @@ trait Method
2322
{
2423
abstract public function __phpunit_getInvocationHandler(): InvocationHandler;
2524

26-
public function method(Constraint|PropertyHook|string $constraint): InvocationMocker
25+
public function method(Constraint|PropertyHook|string $constraint): InvocationStubberImplementation
2726
{
2827
return $this
2928
->__phpunit_getInvocationHandler()

src/Framework/MockObject/Runtime/Api/MockObjectApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
namespace PHPUnit\Framework\MockObject;
1111

12-
use PHPUnit\Framework\MockObject\Builder\InvocationMocker as InvocationMockerBuilder;
12+
use PHPUnit\Framework\MockObject\InvocationStubberImplementation as InvocationMockerBuilder;
1313
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
1414

1515
/**

src/Framework/MockObject/Runtime/Builder/Identity.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Framework/MockObject/Runtime/Builder/MethodNameMatch.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Framework/MockObject/Runtime/Builder/ParametersMatch.php

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/Framework/MockObject/Runtime/Builder/Stub.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Framework/MockObject/Runtime/Builder/InvocationStubber.php renamed to src/Framework/MockObject/Runtime/Interface/InvocationStubber.php

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
namespace PHPUnit\Framework\MockObject\Builder;
10+
namespace PHPUnit\Framework\MockObject;
1111

12+
use PHPUnit\Framework\Constraint\Constraint;
1213
use PHPUnit\Framework\MockObject\Stub\Stub;
1314
use Throwable;
1415

@@ -17,24 +18,70 @@
1718
*/
1819
interface InvocationStubber
1920
{
20-
public function will(Stub $stub): Identity;
21+
/**
22+
* @return $this
23+
*/
24+
public function method(Constraint|string $constraint): self;
25+
26+
/**
27+
* @return $this
28+
*/
29+
public function after(string $id): self;
30+
31+
/**
32+
* @return $this
33+
*/
34+
public function with(mixed ...$arguments): self;
35+
36+
/**
37+
* @return $this
38+
*/
39+
public function withAnyParameters(): self;
40+
41+
/**
42+
* @return $this
43+
*/
44+
public function will(Stub $stub): self;
2145

46+
/**
47+
* @return $this
48+
*/
2249
public function willReturn(mixed $value, mixed ...$nextValues): self;
2350

51+
/**
52+
* @return $this
53+
*/
2454
public function willReturnReference(mixed &$reference): self;
2555

2656
/**
2757
* @param array<int, array<int, mixed>> $valueMap
58+
*
59+
* @return $this
2860
*/
2961
public function willReturnMap(array $valueMap): self;
3062

63+
/**
64+
* @return $this
65+
*/
3166
public function willReturnArgument(int $argumentIndex): self;
3267

68+
/**
69+
* @return $this
70+
*/
3371
public function willReturnCallback(callable $callback): self;
3472

73+
/**
74+
* @return $this
75+
*/
3576
public function willReturnSelf(): self;
3677

78+
/**
79+
* @return $this
80+
*/
3781
public function willReturnOnConsecutiveCalls(mixed ...$values): self;
3882

83+
/**
84+
* @return $this
85+
*/
3986
public function willThrowException(Throwable $exception): self;
4087
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
*/
1010
namespace PHPUnit\Framework\MockObject;
1111

12-
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
1312
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
1413

1514
/**
1615
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
1716
*/
1817
interface MockObject extends Stub
1918
{
20-
public function expects(InvocationOrder $invocationRule): InvocationMocker;
19+
public function expects(InvocationOrder $invocationRule): InvocationStubber;
2120
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace PHPUnit\Framework\MockObject;
1111

1212
use PHPUnit\Framework\Constraint\Constraint;
13-
use PHPUnit\Framework\MockObject\Builder\InvocationStubber;
1413
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;
1514

1615
/**

src/Framework/MockObject/Runtime/InvocationHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use function strtolower;
1313
use Exception;
14-
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
1514
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
1615
use Throwable;
1716

@@ -81,12 +80,12 @@ public function registerMatcher(string $id, Matcher $matcher): void
8180
$this->matcherMap[$id] = $matcher;
8281
}
8382

84-
public function expects(InvocationOrder $rule): InvocationMocker
83+
public function expects(InvocationOrder $rule): InvocationStubberImplementation
8584
{
8685
$matcher = new Matcher($rule);
8786
$this->addMatcher($matcher);
8887

89-
return new InvocationMocker(
88+
return new InvocationStubberImplementation(
9089
$this,
9190
$matcher,
9291
...$this->configurableMethods,

0 commit comments

Comments
 (0)