Skip to content

Commit adef473

Browse files
Merge branch '10.5' into 11.5
2 parents 17ab800 + 95312d9 commit adef473

File tree

4 files changed

+74
-13
lines changed

4 files changed

+74
-13
lines changed

ChangeLog-11.5.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 11.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [11.5.39] - 2025-MM-DD
6+
7+
### Changed
8+
9+
* [#6366](https://github.com/sebastianbergmann/phpunit/issues/6366): Exclude `__sleep()` and `__wakeup()` from test double code generation on PHP >= 8.5
10+
511
## [11.5.38] - 2025-09-11
612

713
### Changed
@@ -338,6 +344,7 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi
338344
* [#6055](https://github.com/sebastianbergmann/phpunit/issues/6055): `assertNotContainsOnly()` (use `assertContainsNotOnlyArray()`, `assertContainsNotOnlyBool()`, `assertContainsNotOnlyCallable()`, `assertContainsNotOnlyFloat()`, `assertContainsNotOnlyInt()`, `assertContainsNotOnlyIterable()`, `assertContainsNotOnlyNumeric()`, `assertContainsNotOnlyObject()`, `assertContainsNotOnlyResource()`, `assertContainsNotOnlyClosedResource()`, `assertContainsNotOnlyScalar()`, or `assertContainsNotOnlyString()` instead)
339345
* [#6059](https://github.com/sebastianbergmann/phpunit/issues/6059): `containsOnly()` (use `containsOnlyArray()`, `containsOnlyBool()`, `containsOnlyCallable()`, `containsOnlyFloat()`, `containsOnlyInt()`, `containsOnlyIterable()`, `containsOnlyNumeric()`, `containsOnlyObject()`, `containsOnlyResource()`, `containsOnlyClosedResource()`, `containsOnlyScalar()`, or `containsOnlyString()` instead)
340346

347+
[11.5.39]: https://github.com/sebastianbergmann/phpunit/compare/11.5.38...11.5
341348
[11.5.38]: https://github.com/sebastianbergmann/phpunit/compare/11.5.37...11.5.38
342349
[11.5.37]: https://github.com/sebastianbergmann/phpunit/compare/11.5.36...11.5.37
343350
[11.5.36]: https://github.com/sebastianbergmann/phpunit/compare/11.5.35...11.5.36

src/Framework/MockObject/Generator/Generator.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,7 @@ final class Generator
8888
/**
8989
* @var array<non-empty-string, true>
9090
*/
91-
private const EXCLUDED_METHOD_NAMES = [
92-
'__CLASS__' => true,
93-
'__DIR__' => true,
94-
'__FILE__' => true,
95-
'__FUNCTION__' => true,
96-
'__LINE__' => true,
97-
'__METHOD__' => true,
98-
'__NAMESPACE__' => true,
99-
'__TRAIT__' => true,
100-
'__clone' => true,
101-
'__halt_compiler' => true,
102-
];
91+
private static $excludedMethodNames = [];
10392

10493
/**
10594
* @var array<non-empty-string, MockClass>
@@ -1014,7 +1003,27 @@ private function canMethodBeDoubled(ReflectionMethod $method): bool
10141003

10151004
private function isMethodNameExcluded(string $name): bool
10161005
{
1017-
return isset(self::EXCLUDED_METHOD_NAMES[$name]);
1006+
if (self::$excludedMethodNames === []) {
1007+
self::$excludedMethodNames = [
1008+
'__CLASS__' => true,
1009+
'__DIR__' => true,
1010+
'__FILE__' => true,
1011+
'__FUNCTION__' => true,
1012+
'__LINE__' => true,
1013+
'__METHOD__' => true,
1014+
'__NAMESPACE__' => true,
1015+
'__TRAIT__' => true,
1016+
'__clone' => true,
1017+
'__halt_compiler' => true,
1018+
];
1019+
1020+
if (version_compare(PHP_VERSION, '8.5', '>=')) {
1021+
self::$excludedMethodNames['__sleep'] = true;
1022+
self::$excludedMethodNames['__wakeup'] = true;
1023+
}
1024+
}
1025+
1026+
return isset(self::$excludedMethodNames[$name]);
10181027
}
10191028

10201029
/**
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6366
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/6366/Issue6366Test.php';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
11+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
12+
--EXPECTF--
13+
PHPUnit %s by Sebastian Bergmann and contributors.
14+
15+
Runtime: %s
16+
17+
. 1 / 1 (100%)
18+
19+
Time: %s, Memory: %s
20+
21+
OK (1 test, 0 assertions)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Issue6366;
11+
12+
use Exception;
13+
use PHPUnit\Framework\TestCase;
14+
15+
final class Issue6366Test extends TestCase
16+
{
17+
/**
18+
* @doesNotPerformAssertions
19+
*/
20+
public function testOne(): void
21+
{
22+
$this->createStub(Exception::class);
23+
}
24+
}

0 commit comments

Comments
 (0)