Skip to content

Commit eea0074

Browse files
committed
🐛 fix grumphp run
1 parent e5d39f3 commit eea0074

File tree

6 files changed

+26
-20
lines changed

6 files changed

+26
-20
lines changed

.github/workflows/run-grumphp-test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ jobs:
77
fail-fast: false
88
matrix:
99
php:
10-
- '8.0'
1110
- '8.1'
1211
- '8.2'
12+
- '8.3'
13+
- '8.4'
1314
container:
1415
image: kanti/buildy:${{ matrix.php }}
1516
steps:
1617
- uses: actions/checkout@v2
17-
- run: composer install --no-progress --no-scripts -n
18+
- run: COMPOSER_ROOT_VERSION=1.99.99 composer install --no-progress --no-scripts -n
1819
- run: ./vendor/bin/grumphp run

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
composer.lock
3+
var/

composer.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
{
22
"name": "andersundsehr/phpstan-git-files",
33
"description": "Add all git files into phpstan config automatically",
4+
"license": "LGPL-3.0-or-later",
45
"type": "library",
5-
"license" : "LGPL-3.0-or-later",
66
"authors": [
77
{
88
"name": "Matthias Vogel",
99
"email": "m.vogel@andersundsehr.com"
1010
}
1111
],
1212
"require": {
13-
"phpstan/phpstan": "^1.9",
14-
"php": "~8.0 || ~8.1 || ~8.2",
15-
"composer-plugin-api" : "^2.1.0"
13+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
14+
"composer-plugin-api": "^2.1.0",
15+
"phpstan/phpstan": "^1.9"
16+
},
17+
"require-dev": {
18+
"pluswerk/grumphp-config": "^7.1.0"
1619
},
1720
"config": {
18-
"sort-packages": true,
1921
"allow-plugins": {
22+
"ergebnis/composer-normalize": true,
2023
"phpro/grumphp": true,
2124
"phpstan/extension-installer": true,
2225
"pluswerk/grumphp-config": true
23-
}
26+
},
27+
"sort-packages": true
2428
},
25-
"require-dev": {
26-
"pluswerk/grumphp-config": "^6.1"
29+
"scripts": {
30+
"post-update-cmd": [
31+
"composer bump -D",
32+
"composer normalize"
33+
]
2734
}
2835
}

extension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
22

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)));
55

66
$command = <<<BASH
77
git ls-files | xargs ls -d 2>/dev/null | grep '\.php$' | awk -v cwd="$(pwd)" '{print cwd "/" $0}'
88
BASH;
99
$absoluteFiles = $exec($command);
1010

1111
// 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, '/'));
1313
$deepestDirectory = dirname($absoluteFiles[0]) . '/';
1414

1515
//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));
1717
// add directory, We add this so the cache is not ignored. see https://github.com/andersundsehr/phpstan-git-files/issues/3
1818
array_unshift($absoluteFiles, $deepestDirectory);
1919

2020
$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}'
2222
BASH;
2323
$absoluteIgnoredFiles = $exec($command);
2424

phpstan-baseline.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
parameters:

rector.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
$rectorConfig->cacheDirectory('./var/cache/rector');
1515

1616
$rectorConfig->paths(
17-
array_filter([
18-
is_dir(__DIR__ . '/src') ? __DIR__ . '/src' : null,
19-
is_dir(__DIR__ . '/extensions') ? __DIR__ . '/extensions' : null,
20-
is_dir(__DIR__ . '/Classes') ? __DIR__ . '/Classes' : null,
21-
])
17+
array_filter(explode("\n", (string)shell_exec("git ls-files | xargs ls -d 2>/dev/null | grep -E '\.(php)$'")))
2218
);
2319

2420
// define sets of rules

0 commit comments

Comments
 (0)