|
1 | 1 | <?php |
2 | 2 |
|
3 | | -return $GLOBALS['andersundsehr/phpstan-git-files.memory-cache'] ??= (function () { |
4 | | - $exec = fn(string $command) => array_filter(explode("\n", (string)shell_exec($command))); |
| 3 | +return $GLOBALS['andersundsehr/phpstan-git-files.memory-cache'] ??= (function (): array { |
| 4 | + $exec = fn(string $command): array => array_filter(explode("\n", (string)shell_exec($command))); |
5 | 5 |
|
6 | 6 | $command = <<<BASH |
7 | 7 | git ls-files | xargs ls -d 2>/dev/null | grep '\.php$' | awk -v cwd="$(pwd)" '{print cwd "/" $0}' |
8 | 8 | BASH; |
9 | 9 | $absoluteFiles = $exec($command); |
10 | 10 |
|
11 | 11 | // sort paths by amount of slashes high count first |
12 | | - usort($absoluteFiles, static fn($a, $b) => substr_count($b, '/') <=> substr_count($a, '/')); |
| 12 | + usort($absoluteFiles, static fn($a, $b): int => substr_count($b, '/') <=> substr_count($a, '/')); |
13 | 13 | $deepestDirectory = dirname($absoluteFiles[0]) . '/'; |
14 | 14 |
|
15 | 15 | //filter all files in that directory |
16 | | - $absoluteFiles = array_filter($absoluteFiles, static fn($path) => !str_starts_with($path, $deepestDirectory)); |
| 16 | + $absoluteFiles = array_filter($absoluteFiles, static fn($path): bool => !str_starts_with($path, $deepestDirectory)); |
17 | 17 | // add directory, We add this so the cache is not ignored. see https://github.com/andersundsehr/phpstan-git-files/issues/3 |
18 | 18 | array_unshift($absoluteFiles, $deepestDirectory); |
19 | 19 |
|
20 | 20 | $command = <<<BASH |
21 | | - git status --ignored --porcelain $deepestDirectory | awk -v cwd="$(pwd)" '/^!!/ {print cwd "/" $2}' |
| 21 | + git status --ignored --porcelain {$deepestDirectory} | awk -v cwd="$(pwd)" '/^!!/ {print cwd "/" $2}' |
22 | 22 | BASH; |
23 | 23 | $absoluteIgnoredFiles = $exec($command); |
24 | 24 |
|
|
0 commit comments