From 0613a55494c9b3466de23384ada59d69eb851d5d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 11 Jul 2024 12:54:52 +0200 Subject: [PATCH] Fix expectations as php8 polyfills are loaded by phpstan.phar --- composer.json | 4 ++-- tests/BaseTestCase.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index ec707cc..f81a2e4 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ } }, "scripts": { - "test": "vendor/bin/phpunit", - "phpstan": "phpstan analyse" + "test": "@php vendor/bin/phpunit", + "phpstan": "@php phpstan analyse" } } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 4db4409..1ccb601 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -37,7 +37,7 @@ protected function doExpectWarning(string $message): void protected function expectPcreEngineException(string $pattern): void { - $error = PHP_VERSION_ID >= 80000 ? 'Backtrack limit exhausted' : 'PREG_BACKTRACK_LIMIT_ERROR'; + $error = function_exists('preg_last_error_msg') ? 'Backtrack limit exhausted' : 'PREG_BACKTRACK_LIMIT_ERROR'; $this->expectPcreException($pattern, $error); } @@ -49,9 +49,9 @@ protected function expectPcreException(string $pattern, ?string $error = null): if (null === $error) { // Only use a message if the error can be reliably determined - if (PHP_VERSION_ID >= 80000) { + if (function_exists('preg_last_error_msg')) { $error = 'Internal error'; - } elseif (PHP_VERSION_ID >= 70201) { + } else { $error = 'PREG_INTERNAL_ERROR'; } }