1
0
Fork 0
composer/phpstan/locate-phpunit-autoloader.php

23 lines
563 B
PHP
Raw Normal View History

2021-12-09 10:35:09 +00:00
<?php
$bestDirFound = null;
$dirs = glob(__DIR__.'/../vendor/bin/.phpunit/phpunit-*', GLOB_ONLYDIR);
2021-12-09 10:35:09 +00:00
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';