Skip to content

Commit d78b5d3

Browse files
committed
phpstan defined in composer.json
1 parent a0fd920 commit d78b5d3

File tree

4 files changed

+93
-48
lines changed

4 files changed

+93
-48
lines changed

.github/workflows/phpstan.yaml

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,33 @@ on:
99
jobs:
1010
phpstan:
1111
runs-on: ubuntu-latest
12+
# define every php version to test
13+
strategy:
14+
# do not stop at first fail
15+
fail-fast: false
16+
matrix:
17+
php: [7.4, 8.2]
18+
1219
steps:
1320
- uses: actions/checkout@v4
1421

15-
- name: Setup PHP 7.4 for dependencies
22+
- name: Setup PHP ${{ matrix.php }} for dependencies
1623
uses: shivammathur/setup-php@v2
1724
with:
18-
php-version: 7.4
25+
php-version: ${{ matrix.php }}
1926

2027
- name: Install Dependencies
2128
run: composer update --ignore-platform-reqs
2229

23-
- name: Setup PHP 8.2 for PHPStan
24-
uses: shivammathur/setup-php@v2
25-
with:
26-
php-version: 8.2
27-
2830
- name: Restore PHPStan cache
2931
id: cache-phpstan
3032
uses: actions/cache/restore@v3
3133
with:
3234
path: phpstan.phar
3335
key: phpstan-1
3436

35-
- name: Download PHPStan
36-
if: steps.cache-phpstan.outputs.cache-hit != 'true'
37-
run: wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar
38-
3937
- name: Run PHPStan
40-
run: php phpstan.phar analyse --configuration phpstan.neon
38+
run: vendor/bin/phpstan analyse --configuration phpstan.neon
4139

4240
update-baseline:
4341
needs: phpstan
@@ -50,9 +48,7 @@ jobs:
5048

5149
- name: Delete existing branch if exists
5250
run: |
53-
if git ls-remote --heads origin update-phpstan-baseline | grep update-phpstan-baseline; then
54-
git push origin --delete update-phpstan-baseline
55-
fi
51+
git ls-remote --exit-code --heads origin update-phpstan-baseline && git push origin --delete update-phpstan-baseline
5652
5753
- name: Setup PHP 7.4 for dependencies
5854
uses: shivammathur/setup-php@v2
@@ -62,19 +58,11 @@ jobs:
6258
- name: Install Dependencies
6359
run: composer update --ignore-platform-reqs
6460

65-
- name: Setup PHP 8.2 for PHPStan
66-
uses: shivammathur/setup-php@v2
67-
with:
68-
php-version: 8.2
69-
70-
- name: Download PHPStan
71-
run: wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar
72-
7361
- name: Generate new baseline
7462
id: generate-baseline
7563
run: |
7664
cp phpstan-baseline.neon phpstan-baseline.neon.old
77-
php phpstan.phar analyse --configuration phpstan.neon --generate-baseline
65+
vendor/bin/phpstan analyse --configuration phpstan.neon --generate-baseline
7866
if ! diff -q phpstan-baseline.neon phpstan-baseline.neon.old > /dev/null; then
7967
echo "baseline_changed=true" >> $GITHUB_OUTPUT
8068
fi

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
"platform": {
1616
"php": "7.4"
1717
}
18+
},
19+
"require-dev": {
20+
"phpstan/phpstan": "^2.1"
1821
}
1922
}

composer.lock

Lines changed: 75 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/fr_FR/static-analysis/phpstan.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22

33
## Installation locale
44

5-
1. Télécharger PHPStan :
6-
```bash
7-
wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar
8-
```
9-
10-
2. Mettre à jour les dépendances :
5+
Mettre à jour les dépendances :
116
```bash
127
composer update --ignore-platform-reqs
138
```
@@ -43,7 +38,7 @@ Notes importantes :
4338
4439
### Lancer l'analyse
4540
```bash
46-
php phpstan.phar analyse --configuration phpstan.neon
41+
vendor/bin/phpstan analyse --configuration phpstan.neon
4742
```
4843

4944
### Types d'erreurs courantes et solutions
@@ -102,7 +97,7 @@ $resultat = codeProblematiqueQuiNeDoitPasEtreModifie();
10297
### Générer un nouveau baseline
10398
Si de nombreuses erreurs existantes doivent être ignorées :
10499
```bash
105-
php phpstan.phar analyse --configuration phpstan.neon --generate-baseline
100+
vendor/bin/phpstan analyse --configuration phpstan.neon --generate-baseline
106101
```
107102

108103
## Intégration continue

0 commit comments

Comments
 (0)