From d3a073bae56feffeb8ff0220ac7c7e77e37f26e5 Mon Sep 17 00:00:00 2001 From: W0rma Date: Fri, 2 Feb 2024 11:27:33 +0100 Subject: [PATCH] Support PHPUnit 11 Generator::testDouble() does now have an additional parameter --- composer.json | 2 +- src/Stub.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 522151e..23651e3 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/src/Stub.php b/src/Stub.php index aaee8bc..d57db23 100644 --- a/src/Stub.php +++ b/src/Stub.php @@ -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]); }