Skip to content

Commit

Permalink
Support PHPUnit 11
Browse files Browse the repository at this point in the history
Generator::testDouble() does now have an additional parameter
  • Loading branch information
W0rma committed Feb 2, 2024
1 parent f6bc56e commit d3a073b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"require": {
"php": "^7.4 | ^8.0",
"phpunit/phpunit": "^8.4 | ^9.0 | ^10.0 | 10.0.x-dev"
"phpunit/phpunit": "^8.4 | ^9.0 | ^10.0 | ^11"
},
"require-dev": {
"consolidation/robo": "^3.0"
Expand Down
14 changes: 13 additions & 1 deletion src/Stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,19 @@ public static function constructEmptyExcept(
private static function generateMock()
{
$args = func_get_args();
if (version_compare(PHPUnitVersion::series(), '10.4', '>=') && !is_bool($args[1])) {
if (version_compare(PHPUnitVersion::series(), '11', '>=')) {
if (!is_bool($args[1]) || !is_bool($args[2])) {
$additionalParameters = [];
if (!is_bool($args[1])) {
$additionalParameters[] = true;
}
if (!is_bool($args[2])) {
$additionalParameters[] = true;
}

array_splice($args, 1, 0, $additionalParameters);
}
} elseif (version_compare(PHPUnitVersion::series(), '10.4', '>=') && !is_bool($args[1])) {
array_splice($args, 1, 0, [true]);
}

Expand Down

0 comments on commit d3a073b

Please sign in to comment.