From 59b331b95fa0f81406cb7d1cebae9e690bada7e3 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 14 Jan 2024 17:35:18 +0100 Subject: [PATCH] Closes #5662 --- ChangeLog-10.5.md | 7 ++++++ phpunit | 55 ++++++++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/ChangeLog-10.5.md b/ChangeLog-10.5.md index 7ba9b75bfe6..aaa4d6011aa 100644 --- a/ChangeLog-10.5.md +++ b/ChangeLog-10.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [10.5.7] - 2024-MM-DD + +### Fixed + +* [#5662](https://github.com/sebastianbergmann/phpunit/issues/5662): PHPUnit errors out on startup when the `ctype` extension is not loaded but a polyfill for it was installed + ## [10.5.6] - 2024-01-13 ### Added @@ -79,6 +85,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi * [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification +[10.5.7]: https://github.com/sebastianbergmann/phpunit/compare/10.5.6...10.5 [10.5.6]: https://github.com/sebastianbergmann/phpunit/compare/10.5.5...10.5.6 [10.5.5]: https://github.com/sebastianbergmann/phpunit/compare/10.5.4...10.5.5 [10.5.4]: https://github.com/sebastianbergmann/phpunit/compare/10.5.3...10.5.4 diff --git a/phpunit b/phpunit index 3a6e3bca6f1..95aaf92d9ea 100755 --- a/phpunit +++ b/phpunit @@ -38,31 +38,6 @@ if (version_compare('8.1.0', PHP_VERSION, '>')) { die(1); } -$requiredExtensions = ['ctype', 'dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter']; - -$unavailableExtensions = array_filter( - $requiredExtensions, - static function ($extension) { - return !extension_loaded($extension); - } -); - -if ([] !== $unavailableExtensions) { - fwrite( - STDERR, - sprintf( - 'PHPUnit requires the "%s" extensions, but the "%s" %s not available.' . PHP_EOL, - implode('", "', $requiredExtensions), - implode('", "', $unavailableExtensions), - count($unavailableExtensions) === 1 ? 'extension is' : 'extensions are' - ) - ); - - die(1); -} - -unset($requiredExtensions, $unavailableExtensions); - if (!ini_get('date.timezone')) { ini_set('date.timezone', 'UTC'); } @@ -96,4 +71,34 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL')) { require PHPUNIT_COMPOSER_INSTALL; +$requiredExtensions = ['dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter']; + +$unavailableExtensions = array_filter( + $requiredExtensions, + static function ($extension) { + return !extension_loaded($extension); + } +); + +// Workaround for https://github.com/sebastianbergmann/phpunit/issues/5662 +if (!function_exists('ctype_alnum')) { + $unavailableExtensions[] = 'ctype'; +} + +if ([] !== $unavailableExtensions) { + fwrite( + STDERR, + sprintf( + 'PHPUnit requires the "%s" extensions, but the "%s" %s not available.' . PHP_EOL, + implode('", "', $requiredExtensions), + implode('", "', $unavailableExtensions), + count($unavailableExtensions) === 1 ? 'extension is' : 'extensions are' + ) + ); + + die(1); +} + +unset($requiredExtensions, $unavailableExtensions); + exit((new PHPUnit\TextUI\Application)->run($_SERVER['argv']));