Skip to content

Commit bebd97a

Browse files
authored
Merge pull request #3256 from kwizer15/feat/phpstan
Migrer PHPStan vers une dépendance Composer (edit #3110)
2 parents e93a437 + 3f0e5b1 commit bebd97a

4 files changed

Lines changed: 83 additions & 43 deletions

File tree

.github/workflows/phpstan.yaml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,44 @@ name: PHPStan
22

33
on:
44
push:
5-
branches: [ alpha ]
5+
branches: [ develop ]
66
pull_request:
7-
branches: [ alpha ]
7+
branches: [ develop ]
88

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
44-
if: github.event_name == 'push' && github.ref == 'refs/heads/alpha'
42+
if: github.event_name == 'push' && github.ref == 'refs/heads/develop'
4543
runs-on: ubuntu-latest
4644
steps:
4745
- uses: actions/checkout@v4
@@ -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
@@ -87,10 +75,10 @@ jobs:
8775
title: '[CI] Update PHPStan baseline'
8876
body: |
8977
Mise à jour automatique du baseline PHPStan suite à la correction d'erreurs.
90-
78+
9179
Cette PR a été générée automatiquement par le workflow CI/CD.
9280
branch: update-phpstan-baseline
93-
base: alpha
81+
base: develop
9482
delete-branch: true
9583
add-paths: |
9684
phpstan-baseline.neon

composer.json

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

composer.lock

Lines changed: 59 additions & 5 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: 4 additions & 9 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
@@ -139,4 +134,4 @@ Un processus automatique a été mis en place pour maintenir le baseline à jour
139134

140135
---
141136

142-
Besoin d'aide supplémentaire ? Consultez la [documentation officielle de PHPStan](https://phpstan.org/user-guide/getting-started).
137+
Besoin d'aide supplémentaire ? Consultez la [documentation officielle de PHPStan](https://phpstan.org/user-guide/getting-started).

0 commit comments

Comments
 (0)