Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sebastianbergmann/phpunit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 12.0.8
Choose a base ref
...
head repository: sebastianbergmann/phpunit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 12.0.9
Choose a head ref
  • 9 commits
  • 13 files changed
  • 1 contributor

Commits on Mar 19, 2025

  1. Update dependencies

    sebastianbergmann committed Mar 19, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2baafc6 View commit details
  2. Merge branch '11.5' into 12.0

    sebastianbergmann committed Mar 19, 2025
    Copy the full SHA
    40f25ec View commit details
  3. Document that this is a fluent API

    sebastianbergmann committed Mar 19, 2025
    Copy the full SHA
    ce4d2fa View commit details
  4. Copy the full SHA
    31366b7 View commit details
  5. Closes #6154

    sebastianbergmann committed Mar 19, 2025
    Copy the full SHA
    fb4df53 View commit details
  6. Do not expose InvocationStubberImplementation

    sebastianbergmann committed Mar 19, 2025
    Copy the full SHA
    8c6d690 View commit details
  7. Prepare release

    sebastianbergmann committed Mar 19, 2025
    Copy the full SHA
    9d60461 View commit details
  8. Copy the full SHA
    3a4ecf2 View commit details
  9. Prepare release

    sebastianbergmann committed Mar 19, 2025
    Copy the full SHA
    7835bb4 View commit details
7 changes: 7 additions & 0 deletions ChangeLog-12.0.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,12 @@

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

## [12.0.9] - 2025-03-19

### Fixed

* [#6154](https://github.com/sebastianbergmann/phpunit/issues/6154): Method `with()` on test doubles yields error with static analyzer

## [12.0.8] - 2025-03-18

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

[12.0.9]: https://github.com/sebastianbergmann/phpunit/compare/12.0.8...12.0.9
[12.0.8]: https://github.com/sebastianbergmann/phpunit/compare/12.0.7...12.0.8
[12.0.7]: https://github.com/sebastianbergmann/phpunit/compare/12.0.6...12.0.7
[12.0.6]: https://github.com/sebastianbergmann/phpunit/compare/12.0.5...12.0.6
3 changes: 1 addition & 2 deletions src/Framework/MockObject/Runtime/Api/Method.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
namespace PHPUnit\Framework\MockObject;

use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount;
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;

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

public function method(Constraint|PropertyHook|string $constraint): InvocationMocker
public function method(Constraint|PropertyHook|string $constraint): InvocationStubber
{
return $this
->__phpunit_getInvocationHandler()
3 changes: 1 addition & 2 deletions src/Framework/MockObject/Runtime/Api/MockObjectApi.php
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
namespace PHPUnit\Framework\MockObject;

use PHPUnit\Framework\MockObject\Builder\InvocationMocker as InvocationMockerBuilder;
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;

/**
@@ -41,7 +40,7 @@ abstract public function __phpunit_getInvocationHandler(): InvocationHandler;

abstract public function __phpunit_unsetInvocationMocker(): void;

public function expects(InvocationOrder $matcher): InvocationMockerBuilder
public function expects(InvocationOrder $matcher): InvocationStubber
{
return $this->__phpunit_getInvocationHandler()->expects($matcher);
}
25 changes: 0 additions & 25 deletions src/Framework/MockObject/Runtime/Builder/Identity.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Framework/MockObject/Runtime/Builder/MethodNameMatch.php

This file was deleted.

51 changes: 0 additions & 51 deletions src/Framework/MockObject/Runtime/Builder/ParametersMatch.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Framework/MockObject/Runtime/Builder/Stub.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -7,8 +7,9 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
namespace PHPUnit\Framework\MockObject;

use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\MockObject\Stub\Stub;
use Throwable;

@@ -17,24 +18,70 @@
*/
interface InvocationStubber
{
public function will(Stub $stub): Identity;
/**
* @return $this
*/
public function method(Constraint|string $constraint): self;

/**
* @return $this
*/
public function after(string $id): self;

/**
* @return $this
*/
public function with(mixed ...$arguments): self;

/**
* @return $this
*/
public function withAnyParameters(): self;

/**
* @return $this
*/
public function will(Stub $stub): self;

/**
* @return $this
*/
public function willReturn(mixed $value, mixed ...$nextValues): self;

/**
* @return $this
*/
public function willReturnReference(mixed &$reference): self;

/**
* @param array<int, array<int, mixed>> $valueMap
*
* @return $this
*/
public function willReturnMap(array $valueMap): self;

/**
* @return $this
*/
public function willReturnArgument(int $argumentIndex): self;

/**
* @return $this
*/
public function willReturnCallback(callable $callback): self;

/**
* @return $this
*/
public function willReturnSelf(): self;

/**
* @return $this
*/
public function willReturnOnConsecutiveCalls(mixed ...$values): self;

/**
* @return $this
*/
public function willThrowException(Throwable $exception): self;
}
3 changes: 1 addition & 2 deletions src/Framework/MockObject/Runtime/Interface/MockObject.php
Original file line number Diff line number Diff line change
@@ -9,13 +9,12 @@
*/
namespace PHPUnit\Framework\MockObject;

use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*/
interface MockObject extends Stub
{
public function expects(InvocationOrder $invocationRule): InvocationMocker;
public function expects(InvocationOrder $invocationRule): InvocationStubber;
}
1 change: 0 additions & 1 deletion src/Framework/MockObject/Runtime/Interface/Stub.php
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
namespace PHPUnit\Framework\MockObject;

use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\MockObject\Builder\InvocationStubber;
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;

/**
5 changes: 2 additions & 3 deletions src/Framework/MockObject/Runtime/InvocationHandler.php
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@

use function strtolower;
use Exception;
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
use Throwable;

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

public function expects(InvocationOrder $rule): InvocationMocker
public function expects(InvocationOrder $rule): InvocationStubber
{
$matcher = new Matcher($rule);
$this->addMatcher($matcher);

return new InvocationMocker(
return new InvocationStubberImplementation(
$this,
$matcher,
...$this->configurableMethods,
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject\Builder;
namespace PHPUnit\Framework\MockObject;

use function array_flip;
use function array_key_exists;
@@ -21,16 +21,6 @@
use function strtolower;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\InvalidArgumentException;
use PHPUnit\Framework\MockObject\ConfigurableMethod;
use PHPUnit\Framework\MockObject\IncompatibleReturnValueException;
use PHPUnit\Framework\MockObject\InvocationHandler;
use PHPUnit\Framework\MockObject\Matcher;
use PHPUnit\Framework\MockObject\MatcherAlreadyRegisteredException;
use PHPUnit\Framework\MockObject\MethodCannotBeConfiguredException;
use PHPUnit\Framework\MockObject\MethodNameAlreadyConfiguredException;
use PHPUnit\Framework\MockObject\MethodNameNotConfiguredException;
use PHPUnit\Framework\MockObject\MethodParametersAlreadyConfiguredException;
use PHPUnit\Framework\MockObject\Rule;
use PHPUnit\Framework\MockObject\Runtime\PropertyHook;
use PHPUnit\Framework\MockObject\Stub\ConsecutiveCalls;
use PHPUnit\Framework\MockObject\Stub\Exception;
@@ -45,8 +35,10 @@

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class InvocationMocker implements InvocationStubber, MethodNameMatch
final class InvocationStubberImplementation implements InvocationStubber
{
private readonly InvocationHandler $invocationHandler;
private readonly Matcher $matcher;
@@ -83,7 +75,7 @@ public function id(string $id): self
/**
* @return $this
*/
public function will(Stub $stub): Identity
public function will(Stub $stub): self
{
$this->matcher->setStub($stub);

2 changes: 1 addition & 1 deletion src/Runner/Version.php
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public static function id(): string
}

if (self::$version === '') {
self::$version = (new VersionId('12.0.8', dirname(__DIR__, 2)))->asString();
self::$version = (new VersionId('12.0.9', dirname(__DIR__, 2)))->asString();
}

return self::$version;