Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions .github/workflows/phpstan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,33 @@ on:
jobs:
phpstan:
runs-on: ubuntu-latest
# define every php version to test
strategy:
# do not stop at first fail
fail-fast: false
matrix:
php: [7.4, 8.2]

steps:
- uses: actions/checkout@v4

- name: Setup PHP 7.4 for dependencies
- name: Setup PHP ${{ matrix.php }} for dependencies
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: ${{ matrix.php }}

- name: Install Dependencies
run: composer update --ignore-platform-reqs

- name: Setup PHP 8.2 for PHPStan
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: Restore PHPStan cache
id: cache-phpstan
uses: actions/cache/restore@v3
with:
path: phpstan.phar
key: phpstan-1

- name: Download PHPStan
if: steps.cache-phpstan.outputs.cache-hit != 'true'
run: wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar

- name: Run PHPStan
run: php phpstan.phar analyse --configuration phpstan.neon
run: vendor/bin/phpstan analyse --configuration phpstan.neon

update-baseline:
needs: phpstan
Expand All @@ -50,9 +48,7 @@ jobs:

- name: Delete existing branch if exists
run: |
if git ls-remote --heads origin update-phpstan-baseline | grep update-phpstan-baseline; then
git push origin --delete update-phpstan-baseline
fi
git ls-remote --exit-code --heads origin update-phpstan-baseline && git push origin --delete update-phpstan-baseline

- name: Setup PHP 7.4 for dependencies
uses: shivammathur/setup-php@v2
Expand All @@ -62,19 +58,11 @@ jobs:
- name: Install Dependencies
run: composer update --ignore-platform-reqs

- name: Setup PHP 8.2 for PHPStan
uses: shivammathur/setup-php@v2
with:
php-version: 8.2

- name: Download PHPStan
run: wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar

- name: Generate new baseline
id: generate-baseline
run: |
cp phpstan-baseline.neon phpstan-baseline.neon.old
php phpstan.phar analyse --configuration phpstan.neon --generate-baseline
vendor/bin/phpstan analyse --configuration phpstan.neon --generate-baseline
if ! diff -q phpstan-baseline.neon phpstan-baseline.neon.old > /dev/null; then
echo "baseline_changed=true" >> $GITHUB_OUTPUT
fi
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"platform": {
"php": "7.4"
}
},
"require-dev": {
"phpstan/phpstan": "^2.1"
}
}
91 changes: 75 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions docs/fr_FR/static-analysis/phpstan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

## Installation locale

1. Télécharger PHPStan :
```bash
wget https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar
```

2. Mettre à jour les dépendances :
Mettre à jour les dépendances :
```bash
composer update --ignore-platform-reqs
```
Expand Down Expand Up @@ -43,7 +38,7 @@ Notes importantes :

### Lancer l'analyse
```bash
php phpstan.phar analyse --configuration phpstan.neon
vendor/bin/phpstan analyse --configuration phpstan.neon
```

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

## Intégration continue
Expand Down