Skip to content

Commit fb4df53

Browse files
Closes #6154
1 parent 31366b7 commit fb4df53

File tree

12 files changed

+43
-152
lines changed

12 files changed

+43
-152
lines changed

ChangeLog-12.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes of the PHPUnit 12.0 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [12.0.9] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6154](https://github.com/sebastianbergmann/phpunit/issues/6154): Method `with()` on test doubles yields error with static analyzer
10+
511
## [12.0.8] - 2025-03-18
612

713
### Changed
@@ -104,6 +110,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi
104110
* [#5801](https://github.com/sebastianbergmann/phpunit/issues/5801): Support for targeting traits with `#[CoversClass]` and `#[UsesClass]` attributes
105111
* [#5978](https://github.com/sebastianbergmann/phpunit/issues/5978): Support for PHP 8.2
106112

113+
[12.0.9]: https://github.com/sebastianbergmann/phpunit/compare/12.0.8...12.0
107114
[12.0.8]: https://github.com/sebastianbergmann/phpunit/compare/12.0.7...12.0.8
108115
[12.0.7]: https://github.com/sebastianbergmann/phpunit/compare/12.0.6...12.0.7
109116
[12.0.6]: https://github.com/sebastianbergmann/phpunit/compare/12.0.5...12.0.6

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: 26 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,7 +18,30 @@
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

2246
/**
2347
* @return $this

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,

src/Framework/MockObject/Runtime/Builder/InvocationMocker.php renamed to src/Framework/MockObject/Runtime/InvocationStubberImplementation.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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

1212
use function array_flip;
1313
use function array_key_exists;
@@ -21,16 +21,6 @@
2121
use function strtolower;
2222
use PHPUnit\Framework\Constraint\Constraint;
2323
use PHPUnit\Framework\InvalidArgumentException;
24-
use PHPUnit\Framework\MockObject\ConfigurableMethod;
25-
use PHPUnit\Framework\MockObject\IncompatibleReturnValueException;
26-
use PHPUnit\Framework\MockObject\InvocationHandler;
27-
use PHPUnit\Framework\MockObject\Matcher;
28-
use PHPUnit\Framework\MockObject\MatcherAlreadyRegisteredException;
29-
use PHPUnit\Framework\MockObject\MethodCannotBeConfiguredException;
30-
use PHPUnit\Framework\MockObject\MethodNameAlreadyConfiguredException;
31-
use PHPUnit\Framework\MockObject\MethodNameNotConfiguredException;
32-
use PHPUnit\Framework\MockObject\MethodParametersAlreadyConfiguredException;
33-
use PHPUnit\Framework\MockObject\Rule;
3424
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;
3525
use PHPUnit\Framework\MockObject\Stub\ConsecutiveCalls;
3626
use PHPUnit\Framework\MockObject\Stub\Exception;
@@ -45,8 +35,10 @@
4535

4636
/**
4737
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
38+
*
39+
* @internal This class is not covered by the backward compatibility promise for PHPUnit
4840
*/
49-
final class InvocationMocker implements InvocationStubber, MethodNameMatch
41+
final class InvocationStubberImplementation implements InvocationStubber
5042
{
5143
private readonly InvocationHandler $invocationHandler;
5244
private readonly Matcher $matcher;
@@ -83,7 +75,7 @@ public function id(string $id): self
8375
/**
8476
* @return $this
8577
*/
86-
public function will(Stub $stub): Identity
78+
public function will(Stub $stub): self
8779
{
8880
$this->matcher->setStub($stub);
8981

0 commit comments

Comments
 (0)