From 1385f81d725ec49e27a56a99506f4028eee48aaf Mon Sep 17 00:00:00 2001 From: Perreal Guillaume <guillaume.perreal@irstea.fr> Date: Fri, 29 Mar 2019 14:01:34 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9coupage=20de=20la=20configuration=20en?= =?UTF-8?q?=20plusieurs=20variantes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 30 ++++++++++++++++-------------- composer.json | 5 +++++ loose.neon | 9 +++++++++ phpstan.neon | 13 +++---------- phpunit.neon | 4 ++++ strict.neon | 5 +++++ symfony.neon | 9 +++++++++ 7 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 loose.neon create mode 100644 phpunit.neon create mode 100644 strict.neon create mode 100644 symfony.neon diff --git a/README.md b/README.md index ba5446d..42420b7 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ Configuration pour phpstan/phpstan. Inclut les extensions PHPStan pour les outils suivant : -- Doctrine -- Symfony -- PHPUnit -- [beberlei/assert](https://github.com/beberlei/assert) -- [phpspec/prophecy](https://github.com/phpspec/prophecy) +- Doctrine => [phpstan/phpstan-doctrine](https://github.com/phpstan/phpstan-doctrine) +- Symfony => [phpstan/phpstan-symfony](https://github.com/phpstan/phpstan-symfony) +- PHPUnit => [phpstan/phpstan-phpunit](https://github.com/phpstan/phpstan-phpunit) +- [beberlei/assert](https://github.com/beberlei/assert) => [phpstan/phpstan-beberlei-assert](https://github.com/phpstan/phpstan-beberlei-assert) +- [phpspec/prophecy](https://github.com/phpspec/prophecy) => [jangregor/phpstan-prophecy](https://github.com/Jan0707/phpstan-prophecy) ### Installation @@ -16,7 +16,15 @@ Inclut les extensions PHPStan pour les outils suivant : composer require --dev irstea/phpstan-config ``` -### Configuration +### Utilisation + +Le paquet fournit plusieurs fichiers de configuration à inclure selon les besoins: + +- [`loose.neon`](loose.neon): vérifications _souples_, +- [`strict.neon`](strict.neon): vérifications _strictes_ (inclut `loose.neon`), +- [`phpunit.neon`](phpunit.neon): à inclure dans les projets utilisant PHPUnit, +- [`symfony.neon`](symfony.neon): à inclure dans les projets utilisant Symfony et Doctrine. +- [`phpstan.neon`](phpstan.neon): `strict.neon` + `phpunit.neon` + `symfony.neon`. Exemple : @@ -30,14 +38,8 @@ parameters: - tests symfony: - container_xml_path: %currentWorkingDirectory%/var/cache/test/srcApp_KernelTestDebugContainer.xml + container_xml_path: %currentWorkingDirectory%/var/cache/test/srcApp_KernelTestDebugContainer.xml ``` -cf. https://github.com/phpstan/phpstan#configuration pour plus de détails. - -### Usage - -```shell -vendor/bin/phpstan analyse -``` +**Note :** `container_xml_path` change selon la version de Symfony, cf. https://github.com/phpstan/phpstan-symfony#usage diff --git a/composer.json b/composer.json index e511272..31a4bd5 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,11 @@ "phpstan/phpstan-phpunit": "^0.11", "phpstan/phpstan-symfony": "^0.11" }, + "suggest": { + "beberlei/assert": "Framework léger d'assertion de type.", + "phpunit/phpunit": "Framework de tests unitaires.", + "phpspec/prophecy": "Framework de mocking pour les tests unitaires." + }, "config": { "sort-packages": true }, diff --git a/loose.neon b/loose.neon new file mode 100644 index 0000000..d5b4a0a --- /dev/null +++ b/loose.neon @@ -0,0 +1,9 @@ +includes: + - ../../phpstan/phpstan-beberlei-assert/extension.neon + +parameters: + level: 1 + memory-limit: 500M + + excludes_analyse: + - %rootDir%/../../vendor diff --git a/phpstan.neon b/phpstan.neon index 584febc..afb02dd 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,11 +1,4 @@ includes: - - ../../phpstan/phpstan-doctrine/extension.neon - - ../../phpstan/phpstan-symfony/extension.neon - - ../../phpstan/phpstan-phpunit/extension.neon - - ../../phpstan/phpstan-phpunit/rules.neon - - ../../jangregor/phpstan-prophecy/src/extension.neon - - ../../phpstan/phpstan-beberlei-assert/extension.neon - -parameters: - level: 7 - memory-limit: 500M + - ./strict.neon + - ./symfony.neon + - ./phpunit.neon diff --git a/phpunit.neon b/phpunit.neon new file mode 100644 index 0000000..ddde8bc --- /dev/null +++ b/phpunit.neon @@ -0,0 +1,4 @@ +includes: + - ../../phpstan/phpstan-phpunit/extension.neon + - ../../phpstan/phpstan-phpunit/rules.neon + - ../../jangregor/phpstan-prophecy/src/extension.neon diff --git a/strict.neon b/strict.neon new file mode 100644 index 0000000..4226301 --- /dev/null +++ b/strict.neon @@ -0,0 +1,5 @@ +includes: + - ./loose.neon + +parameters: + level: 7 diff --git a/symfony.neon b/symfony.neon new file mode 100644 index 0000000..18b95ad --- /dev/null +++ b/symfony.neon @@ -0,0 +1,9 @@ +includes: + - ../../phpstan/phpstan-doctrine/extension.neon + - ../../phpstan/phpstan-doctrine/rules.neon + - ../../phpstan/phpstan-symfony/extension.neon + + excludes_analyse: + - %rootDir%/../../../var + - %rootDir%/../../../app/cache + - %rootDir%/../../../app/logs -- GitLab