@@ -17,23 +17,30 @@ if (version_compare('7.3.0', PHP_VERSION, '>')) {
1717 fwrite (STDERR , sprintf ('This version of PHPUnit requires PHP >= 7.3. ' . PHP_EOL . 'You are using PHP %s (%s). ' . PHP_EOL , PHP_VERSION , PHP_BINARY ));
1818 die (1 );
1919}
20- foreach (['dom ' , 'json ' , 'libxml ' , 'mbstring ' , 'tokenizer ' , 'xml ' , 'xmlwriter ' ] as $ extension ) {
21- if (extension_loaded ($ extension )) {
22- continue ;
23- }
24- fwrite (STDERR , sprintf ('PHPUnit requires the "%s" extension. ' . PHP_EOL , $ extension ));
20+ $ requiredExtensions = ['dom ' , 'json ' , 'libxml ' , 'mbstring ' , 'tokenizer ' , 'xml ' , 'xmlwriter ' ];
21+ $ unavailableExtensions = array_filter ($ requiredExtensions , static function ($ extension ) {
22+ return !extension_loaded ($ extension );
23+ });
24+ if ([] !== $ unavailableExtensions ) {
25+ 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 ' ));
2526 die (1 );
2627}
28+ unset($ requiredExtensions , $ unavailableExtensions );
2729if (!ini_get ('date.timezone ' )) {
2830 ini_set ('date.timezone ' , 'UTC ' );
2931}
30- foreach (array (__DIR__ . '/../../autoload.php ' , __DIR__ . '/../vendor/autoload.php ' , __DIR__ . '/vendor/autoload.php ' ) as $ file ) {
31- if (file_exists ($ file )) {
32- define ('PHPUNIT_COMPOSER_INSTALL ' , $ file );
33- break ;
32+ if (isset ($ GLOBALS ['_composer_autoload_path ' ])) {
33+ define ('PHPUNIT_COMPOSER_INSTALL ' , $ GLOBALS ['_composer_autoload_path ' ]);
34+ unset($ GLOBALS ['_composer_autoload_path ' ]);
35+ } else {
36+ foreach (array (__DIR__ . '/../../autoload.php ' , __DIR__ . '/../vendor/autoload.php ' , __DIR__ . '/vendor/autoload.php ' ) as $ file ) {
37+ if (file_exists ($ file )) {
38+ define ('PHPUNIT_COMPOSER_INSTALL ' , $ file );
39+ break ;
40+ }
3441 }
42+ unset($ file );
3543}
36- unset($ file );
3744if (!defined ('PHPUNIT_COMPOSER_INSTALL ' )) {
3845 fwrite (STDERR , 'You need to set up the project dependencies using Composer: ' . PHP_EOL . PHP_EOL . ' composer install ' . PHP_EOL . PHP_EOL . 'You can learn all about Composer on https://getcomposer.org/. ' . PHP_EOL );
3946 die (1 );
0 commit comments