From bf74c79dfe83579fc376f85c2b1eba353ad1b762 Mon Sep 17 00:00:00 2001 From: Bart van den Broeck Date: Wed, 3 Dec 2025 16:59:22 +0100 Subject: [PATCH 1/2] update phpunit hook --- .gitlab/ci/test/phpstan.yml | 2 +- src/PHPUnit/Hooks/BypassFinalHook.php | 32 ++++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.gitlab/ci/test/phpstan.yml b/.gitlab/ci/test/phpstan.yml index 4634b0f..a1141c9 100644 --- a/.gitlab/ci/test/phpstan.yml +++ b/.gitlab/ci/test/phpstan.yml @@ -2,7 +2,7 @@ phpstan: stage: test - image: php:8.3-cli-alpine + image: php:8.2-cli-alpine rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' when: on_success diff --git a/src/PHPUnit/Hooks/BypassFinalHook.php b/src/PHPUnit/Hooks/BypassFinalHook.php index 2abe4e5..8334161 100644 --- a/src/PHPUnit/Hooks/BypassFinalHook.php +++ b/src/PHPUnit/Hooks/BypassFinalHook.php @@ -13,24 +13,26 @@ namespace XpertSelect\Tools\PHPUnit\Hooks; use DG\BypassFinals; -/** - * Class BypassFinalHook. - * - * PHPUnit hook to disable `final` modifiers in the PHP codebase to ensure all classes can be - * mocked by libraries such as Mockery. Needed for phpunit v9. - * - * @internal - */ -final class BypassFinalHook -{ +if (interface_exists('PHPUnit\Runner\BeforeTestHook')) { /** - * Disable any `final` modifiers prior to executing the test to ensure that final classes can - * properly be mocked during tests. + * Class BypassFinalHook. + * + * PHPUnit hook to disable `final` modifiers in the PHP codebase to ensure all classes can be + * mocked by libraries such as Mockery. Needed for phpunit v9. * - * @param string $test The name of the test being executed + * @internal */ - public function executeBeforeTest(string $test): void + final class BypassFinalHook implements \PHPUnit\Runner\BeforeTestHook { - BypassFinals::enable(); + /** + * Disable any `final` modifiers prior to executing the test to ensure that final classes can + * properly be mocked during tests. + * + * @param string $test The name of the test being executed + */ + public function executeBeforeTest(string $test): void + { + BypassFinals::enable(); + } } } -- GitLab From bc725f194b42dbd3b895fa08462a4c455df3de84 Mon Sep 17 00:00:00 2001 From: Bart van den Broeck Date: Wed, 3 Dec 2025 17:05:48 +0100 Subject: [PATCH 2/2] cs-fixer? --- src/PHPUnit/Hooks/BypassFinalHook.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PHPUnit/Hooks/BypassFinalHook.php b/src/PHPUnit/Hooks/BypassFinalHook.php index 8334161..050e2e0 100644 --- a/src/PHPUnit/Hooks/BypassFinalHook.php +++ b/src/PHPUnit/Hooks/BypassFinalHook.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace XpertSelect\Tools\PHPUnit\Hooks; use DG\BypassFinals; +use PHPUnit\Runner\BeforeTestHook; if (interface_exists('PHPUnit\Runner\BeforeTestHook')) { /** @@ -22,7 +23,7 @@ if (interface_exists('PHPUnit\Runner\BeforeTestHook')) { * * @internal */ - final class BypassFinalHook implements \PHPUnit\Runner\BeforeTestHook + final class BypassFinalHook implements BeforeTestHook { /** * Disable any `final` modifiers prior to executing the test to ensure that final classes can -- GitLab