From 4ea7ea5edc88295cfb4eb8d50184aca3f5aa8947 Mon Sep 17 00:00:00 2001 From: pifou25 Date: Sat, 2 Aug 2025 12:31:04 +0200 Subject: [PATCH] phpstan defined in composer.json --- .github/workflows/phpstan.yaml | 36 ++-- composer.json | 3 + composer.lock | 247 ++++++++++++++++---------- docs/fr_FR/static-analysis/phpstan.md | 11 +- 4 files changed, 171 insertions(+), 126 deletions(-) diff --git a/.github/workflows/phpstan.yaml b/.github/workflows/phpstan.yaml index 8d90800544..53cb8423eb 100644 --- a/.github/workflows/phpstan.yaml +++ b/.github/workflows/phpstan.yaml @@ -9,22 +9,24 @@ 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 @@ -32,12 +34,8 @@ jobs: 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 @@ -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 @@ -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 diff --git a/composer.json b/composer.json index 607694c32b..8bd5350b62 100644 --- a/composer.json +++ b/composer.json @@ -16,5 +16,8 @@ "platform": { "php": "7.4" } + }, + "require-dev": { + "phpstan/phpstan": "^2.1" } } diff --git a/composer.lock b/composer.lock index 3c89db4378..53b8a65e09 100644 --- a/composer.lock +++ b/composer.lock @@ -4,59 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "be46045c22daf0366a838f96eed56caf", + "content-hash": "d2faa51c0ec5175dc36b46b3356938d9", "packages": [ - { - "name": "abbadon1334/sun-position-spa-php", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/abbadon1334/sun-position-spa-php.git", - "reference": "26244d51284ae80061dc21f26d4b1c31672354bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/abbadon1334/sun-position-spa-php/zipball/26244d51284ae80061dc21f26d4b1c31672354bf", - "reference": "26244d51284ae80061dc21f26d4b1c31672354bf", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "require-dev": { - "codacy/coverage": "dev-master", - "friendsofphp/php-cs-fixer": "dev-master@dev", - "phpmd/phpmd": "2.6.0", - "phpmetrics/phpmetrics": "dev-master@dev", - "phpstan/phpstan": "0.11.5", - "phpunit/phpunit": "*", - "squizlabs/php_codesniffer": "3.4.2", - "symfony/yaml": "~2.1|~3.0|~4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "SolarData\\": "src/", - "SolarData\\Tests\\": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Francesco Danti", - "email": "fdanti@gmail.com" - } - ], - "description": "solar data calculation and sun position", - "support": { - "issues": "https://github.com/abbadon1334/sun-position-spa-php/issues", - "source": "https://github.com/abbadon1334/sun-position-spa-php/tree/master" - }, - "time": "2019-07-08T09:51:15+00:00" - }, { "name": "bacon/bacon-qr-code", "version": "2.0.8", @@ -179,16 +128,16 @@ }, { "name": "dasprid/enum", - "version": "1.0.7", + "version": "1.0.6", "source": { "type": "git", "url": "https://github.com/DASPRiD/Enum.git", - "reference": "b5874fa9ed0043116c72162ec7f4fb50e02e7cce" + "reference": "8dfd07c6d2cf31c8da90c53b83c026c7696dda90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/b5874fa9ed0043116c72162ec7f4fb50e02e7cce", - "reference": "b5874fa9ed0043116c72162ec7f4fb50e02e7cce", + "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8dfd07c6d2cf31c8da90c53b83c026c7696dda90", + "reference": "8dfd07c6d2cf31c8da90c53b83c026c7696dda90", "shasum": "" }, "require": { @@ -223,34 +172,35 @@ ], "support": { "issues": "https://github.com/DASPRiD/Enum/issues", - "source": "https://github.com/DASPRiD/Enum/tree/1.0.7" + "source": "https://github.com/DASPRiD/Enum/tree/1.0.6" }, - "time": "2025-09-16T12:23:56+00:00" + "time": "2024-08-09T14:30:48+00:00" }, { "name": "dragonmantank/cron-expression", - "version": "v3.5.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/dragonmantank/cron-expression.git", - "reference": "1b2de7f4a468165dca07b142240733a1973e766d" + "reference": "8c784d071debd117328803d86b2097615b457500" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/1b2de7f4a468165dca07b142240733a1973e766d", - "reference": "1b2de7f4a468165dca07b142240733a1973e766d", + "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/8c784d071debd117328803d86b2097615b457500", + "reference": "8c784d071debd117328803d86b2097615b457500", "shasum": "" }, "require": { - "php": "^7.2|^8.0" + "php": "^7.2|^8.0", + "webmozart/assert": "^1.0" }, "replace": { "mtdowling/cron-expression": "^1.0" }, "require-dev": { - "phpstan/extension-installer": "^1.4.3", - "phpstan/phpstan": "^1.12.32|^2.1.31", - "phpunit/phpunit": "^8.5.48|^9.0" + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0" }, "type": "library", "extra": { @@ -281,7 +231,7 @@ ], "support": { "issues": "https://github.com/dragonmantank/cron-expression/issues", - "source": "https://github.com/dragonmantank/cron-expression/tree/v3.5.0" + "source": "https://github.com/dragonmantank/cron-expression/tree/v3.4.0" }, "funding": [ { @@ -289,7 +239,7 @@ "type": "github" } ], - "time": "2025-10-31T18:36:32+00:00" + "time": "2024-10-09T13:47:03+00:00" }, { "name": "influxdata/influxdb-client-php", @@ -343,16 +293,16 @@ }, { "name": "paragonie/constant_time_encoding", - "version": "v2.8.2", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "e30811f7bc69e4b5b6d5783e712c06c8eabf0226" + "reference": "52a0d99e69f56b9ec27ace92ba56897fe6993105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/e30811f7bc69e4b5b6d5783e712c06c8eabf0226", - "reference": "e30811f7bc69e4b5b6d5783e712c06c8eabf0226", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/52a0d99e69f56b9ec27ace92ba56897fe6993105", + "reference": "52a0d99e69f56b9ec27ace92ba56897fe6993105", "shasum": "" }, "require": { @@ -406,7 +356,7 @@ "issues": "https://github.com/paragonie/constant_time_encoding/issues", "source": "https://github.com/paragonie/constant_time_encoding" }, - "time": "2025-09-24T15:12:37+00:00" + "time": "2024-05-08T12:18:48+00:00" }, { "name": "php-http/client-common", @@ -788,21 +738,21 @@ }, { "name": "pragmarx/google2fa-qrcode", - "version": "v3.0.1", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/antonioribeiro/google2fa-qrcode.git", - "reference": "c23ebcc3a50de0d1566016a6dd1486e183bb78e1" + "reference": "ce4d8a729b6c93741c607cfb2217acfffb5bf76b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/antonioribeiro/google2fa-qrcode/zipball/c23ebcc3a50de0d1566016a6dd1486e183bb78e1", - "reference": "c23ebcc3a50de0d1566016a6dd1486e183bb78e1", + "url": "https://api.github.com/repos/antonioribeiro/google2fa-qrcode/zipball/ce4d8a729b6c93741c607cfb2217acfffb5bf76b", + "reference": "ce4d8a729b6c93741c607cfb2217acfffb5bf76b", "shasum": "" }, "require": { "php": ">=7.1", - "pragmarx/google2fa": "^4.0|^5.0|^6.0|^7.0|^8.0" + "pragmarx/google2fa": ">=4.0" }, "require-dev": { "bacon/bacon-qr-code": "^2.0", @@ -849,9 +799,9 @@ ], "support": { "issues": "https://github.com/antonioribeiro/google2fa-qrcode/issues", - "source": "https://github.com/antonioribeiro/google2fa-qrcode/tree/v3.0.1" + "source": "https://github.com/antonioribeiro/google2fa-qrcode/tree/v3.0.0" }, - "time": "2025-09-19T23:02:26+00:00" + "time": "2021-08-15T12:53:48+00:00" }, { "name": "psr/cache", @@ -1537,7 +1487,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.33.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -1593,7 +1543,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0" }, "funding": [ { @@ -1604,10 +1554,6 @@ "url": "https://github.com/fabpot", "type": "github" }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -1617,7 +1563,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.33.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -1677,7 +1623,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" }, "funding": [ { @@ -1688,10 +1634,6 @@ "url": "https://github.com/fabpot", "type": "github" }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -1854,9 +1796,126 @@ } ], "time": "2024-09-25T14:11:13+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.11.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991", + "reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": "^7.2 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.11.0" + }, + "time": "2022-06-03T18:03:27+00:00" + } + ], + "packages-dev": [ + { + "name": "phpstan/phpstan", + "version": "2.1.21", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ccf445757458c06a04eb3f803603cb118fe5fa6", + "reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-07-28T19:35:08+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": {}, @@ -1869,5 +1928,5 @@ "platform-overrides": { "php": "7.4" }, - "plugin-api-version": "2.9.0" + "plugin-api-version": "2.6.0" } diff --git a/docs/fr_FR/static-analysis/phpstan.md b/docs/fr_FR/static-analysis/phpstan.md index 91788ab33b..a69618768f 100644 --- a/docs/fr_FR/static-analysis/phpstan.md +++ b/docs/fr_FR/static-analysis/phpstan.md @@ -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 ``` @@ -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 @@ -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