Issues (7)

src/functions.php (1 issue)

Severity
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * @throws Exception
6
 */
7
function findVendorDirectory(): string
8
{
9 1
    if (isset($GLOBALS["_composer_autoload_path"]) && is_string($GLOBALS["_composer_autoload_path"])) {
10
        return dirname($GLOBALS["_composer_autoload_path"]);
11
    }
12 1
    $recursionLimit = 10;
13 1
    $findVendor = function (string $dirName = "vendor/bin", string $dir = __DIR__) use (&$findVendor, &$recursionLimit): string {
0 ignored issues
show
Line exceeds 120 characters; contains 129 characters
Loading history...
14 1
        $recursionLimit--;
15 1
        if ($recursionLimit === 0) {
16
            throw new Exception("Cannot find vendor directory.");
17
        }
18 1
        $found = $dir . "/$dirName";
19 1
        if (is_dir($found) || is_file($found)) {
20 1
            return dirname($found);
21
        }
22 1
        return $findVendor($dirName, dirname($dir));
23
    };
24 1
    return $findVendor();
25
}
26