From b178f2e04aabd777fa68c61c4616081e6cfc05d7 Mon Sep 17 00:00:00 2001 From: DjordyKoert Date: Sat, 2 Mar 2024 20:36:51 +0100 Subject: [PATCH] add phpstan-symfony & phpstan-phpunit --- composer.json | 11 ++++++++++- phpstan-baseline.neon | 46 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 38baa4543..4ccb41119 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,11 @@ "phpunit/phpunit": "^9.6", "doctrine/annotations": "^2.0", - "phpstan/phpstan": "^1.10" + + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-symfony": "^1.3", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/extension-installer": "^1.3" }, "suggest": { "api-platform/core": "For using an API oriented framework.", @@ -95,5 +99,10 @@ "phpunit": "phpunit", "phpstan": "phpstan analyse --memory-limit=2G", "phpstan-baseline": "phpstan analyse --generate-baseline --memory-limit=2G" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b1d3e36c3..76fd4fba1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -111,7 +111,7 @@ parameters: path: src/Controller/YamlDocumentationController.php - - message: "#^Argument of an invalid type array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null supplied for foreach, only iterables are supported\\.$#" + message: "#^Argument of an invalid type array\\|bool\\|float\\|int\\|string\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 path: src/DependencyInjection/Compiler/TagDescribersPass.php @@ -2100,11 +2100,6 @@ parameters: count: 1 path: src/Util/ControllerReflector.php - - - message: "#^Comparison operation \"\\>\\=\" between 70004 and 40100 is always true\\.$#" - count: 1 - path: src/Util/ControllerReflector.php - - message: "#^Method Nelmio\\\\ApiDocBundle\\\\Util\\\\ControllerReflector\\:\\:getClassAndMethod\\(\\) has no return type specified\\.$#" count: 1 @@ -2981,7 +2976,7 @@ parameters: path: tests/Functional/Controller/UndocumentedController.php - - message: "#^Call to an undefined method object\\:\\:generate\\(\\)\\.$#" + message: "#^Cannot call method generate\\(\\) on object\\|null\\.$#" count: 1 path: tests/Functional/ControllerTest.php @@ -4530,6 +4525,26 @@ parameters: count: 1 path: tests/Functional/FOSRestTest.php + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with '@OA\\\\\\\\Generator\\:…' and OpenApi\\\\Annotations\\\\Post will always evaluate to false\\.$#" + count: 1 + path: tests/Functional/FunctionalTest.php + + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with '@OA\\\\\\\\Generator\\:…' and array\\ will always evaluate to false\\.$#" + count: 4 + path: tests/Functional/FunctionalTest.php + + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with '@OA\\\\\\\\Generator\\:…' and array\\ will always evaluate to false\\.$#" + count: 1 + path: tests/Functional/FunctionalTest.php + + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with '@OA\\\\\\\\Generator\\:…' and bool will always evaluate to false\\.$#" + count: 3 + path: tests/Functional/FunctionalTest.php + - message: "#^Cannot access offset 'application/json' on array\\\\|OpenApi\\\\Annotations\\\\Attachable\\|OpenApi\\\\Annotations\\\\JsonContent\\|OpenApi\\\\Annotations\\\\MediaType\\|OpenApi\\\\Annotations\\\\XmlContent\\.$#" count: 2 @@ -4930,6 +4945,11 @@ parameters: count: 1 path: tests/Functional/SwaggerUiTest.php + - + message: "#^You should use assertCount\\(\\$expectedCount, \\$variable\\) instead of assertSame\\(\\$expectedCount, \\$variable\\-\\>count\\(\\)\\)\\.$#" + count: 1 + path: tests/Functional/SwaggerUiTest.php + - message: "#^Cannot access offset 'parameters' on mixed\\.$#" count: 4 @@ -5021,7 +5041,7 @@ parameters: path: tests/Functional/WebTestCase.php - - message: "#^Call to an undefined method object\\:\\:generate\\(\\)\\.$#" + message: "#^Cannot call method generate\\(\\) on object\\|null\\.$#" count: 1 path: tests/Functional/WebTestCase.php @@ -5780,6 +5800,11 @@ parameters: count: 1 path: tests/ModelDescriber/Fixtures/SelfDescribingModel.php + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with '@OA\\\\\\\\Generator\\:…' and array\\ will always evaluate to false\\.$#" + count: 1 + path: tests/ModelDescriber/FormModelDescriberTest.php + - message: "#^Method Nelmio\\\\ApiDocBundle\\\\Tests\\\\ModelDescriber\\\\FormModelDescriberTest\\:\\:provideCsrfProtectionOptions\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -6075,6 +6100,11 @@ parameters: count: 1 path: tests/SwaggerPhp/UtilTest.php + - + message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertSame\\(\\) with array\\ and stdClass will always evaluate to false\\.$#" + count: 1 + path: tests/SwaggerPhp/UtilTest.php + - message: "#^Cannot access property \\$nested on OpenApi\\\\Context\\|null\\.$#" count: 1