diff --git a/.gitlab/ci/test/phpstan.yml b/.gitlab/ci/test/phpstan.yml index 4634b0f9c5d5eda586c026edc1bf2bae5fdc480b..a1141c9aea9d75c4ca024f7a1cec612ad43892c8 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 2abe4e5b804848f409935c41e79db8f5ae8d4b1f..050e2e05ac7517647aefcaf17d8f0e948c03f3ab 100644 --- a/src/PHPUnit/Hooks/BypassFinalHook.php +++ b/src/PHPUnit/Hooks/BypassFinalHook.php @@ -12,25 +12,28 @@ declare(strict_types=1); namespace XpertSelect\Tools\PHPUnit\Hooks; use DG\BypassFinals; +use PHPUnit\Runner\BeforeTestHook; -/** - * 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 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(); + } } }