1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 16:42:57 +00:00
composer/phpstan/locate-phpunit-autoloader.php
2022-01-01 14:54:20 +01:00

22 lines
563 B
PHP

<?php
$bestDirFound = null;
$dirs = glob(__DIR__.'/../vendor/bin/.phpunit/phpunit-*', GLOB_ONLYDIR);
natsort($dirs);
foreach (array_reverse($dirs) as $dir) {
$bestDirFound = $dir;
if (PHP_VERSION_ID >= 80000 && false !== strpos($dir, 'phpunit-9')) {
break;
}
if (PHP_VERSION_ID < 80000 && false !== strpos($dir, 'phpunit-8')) {
break;
}
}
if (null === $bestDirFound) {
echo 'Run "composer test" to initialize PHPUnit sources before running PHPStan'.PHP_EOL;
exit(1);
}
include $bestDirFound.'/vendor/autoload.php';