File: phpstan-locate-phpunit-autoloader.php

package info (click to toggle)
php-composer-pcre 3.1.0-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 292 kB
  • sloc: php: 1,291; makefile: 19
file content (22 lines) | stat: -rw-r--r-- 589 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

$bestDirFound = null;
$dirs = (array) 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((string) $dir, 'phpunit-9')) {
        break;
    }
    if (PHP_VERSION_ID < 80000 && false !== strpos((string) $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';