Skip to content

Commit cbea5e6

Browse files
committed
phpstan defined in composer.json
1 parent a9ed690 commit cbea5e6

File tree

4 files changed

+99
-46
lines changed

4 files changed

+99
-46
lines changed

.github/workflows/phpstan.yaml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,44 @@ 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
4442
if: github.event_name == 'push' && github.ref == 'refs/heads/alpha'
4543
runs-on: ubuntu-latest
44+
# define every php version to test
45+
strategy:
46+
# do not stop at first fail
47+
fail-fast: false
48+
matrix:
49+
php: [7.4, 8.2]
4650
steps:
4751
- uses: actions/checkout@v4
4852
with:
@@ -54,27 +58,19 @@ jobs:
5458
git push origin --delete update-phpstan-baseline
5559
fi
5660
57-
- name: Setup PHP 7.4 for dependencies
61+
- name: Setup PHP ${{ matrix.php }} for dependencies
5862
uses: shivammathur/setup-php@v2
5963
with:
60-
php-version: 7.4
64+
php-version: ${{ matrix.php }}
6165

6266
- name: Install Dependencies
6367
run: composer update --ignore-platform-reqs
6468

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-
7369
- name: Generate new baseline
7470
id: generate-baseline
7571
run: |
7672
cp phpstan-baseline.neon phpstan-baseline.neon.old
77-
php phpstan.phar analyse --configuration phpstan.neon --generate-baseline
73+
vendor/bin/phpstan analyse --configuration phpstan.neon --generate-baseline
7874
if ! diff -q phpstan-baseline.neon phpstan-baseline.neon.old > /dev/null; then
7975
echo "baseline_changed=true" >> $GITHUB_OUTPUT
8076
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: 2 additions & 7 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+
1. 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

0 commit comments

Comments
 (0)