From 8ce3d1bd4e22ac08add2ce4c56d8a6c39e20c3cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Barto=C5=A1?= Date: Sat, 22 Jun 2024 00:09:37 +0200 Subject: [PATCH] PHPStan: new options --- src/Enum/ParameterIn.php | 14 ++++++++++++-- tools/phpstan.baseline.neon | 15 +++++---------- tools/phpstan.neon | 4 +++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Enum/ParameterIn.php b/src/Enum/ParameterIn.php index 3e53118..c140c97 100644 --- a/src/Enum/ParameterIn.php +++ b/src/Enum/ParameterIn.php @@ -33,15 +33,25 @@ final class ParameterIn 'query' => ['form', 'spaceDelimited', 'pipeDelimited', 'deepObject'], ]; - /** @readonly */ + /** + * @var value-of + * @readonly + */ public string $name; - /** @readonly */ + /** + * @var key-of + * @readonly + */ public string $value; /** @var array */ private static array $instances = []; + /** + * @param value-of $name + * @param key-of $value + */ private function __construct(string $name, string $value) { $this->name = $name; diff --git a/tools/phpstan.baseline.neon b/tools/phpstan.baseline.neon index 890898a..ed6b2f4 100644 --- a/tools/phpstan.baseline.neon +++ b/tools/phpstan.baseline.neon @@ -1,5 +1,10 @@ parameters: ignoreErrors: + - + message: "#^Parameter \\#2 \\$value of class Orisai\\\\OpenAPI\\\\Enum\\\\ParameterIn constructor expects 'cookie'\\|'header'\\|'path'\\|'query', string given\\.$#" + count: 1 + path: ../src/Enum/ParameterIn.php + - message: "#^Parameter \\#1 \\$name of method Orisai\\\\OpenAPI\\\\Spec\\\\Encoding\\:\\:addContentType\\(\\) expects non\\-empty\\-string, string given\\.$#" count: 1 @@ -50,16 +55,6 @@ parameters: count: 1 path: ../tests/Unit/Spec/ResponsesTest.php - - - message: "#^Offset 0 might not exist on list\\\\|null\\.$#" - count: 1 - path: ../tests/Unit/Utils/HeadersTest.php - - - - message: "#^Offset 1 might not exist on list\\\\|null\\.$#" - count: 1 - path: ../tests/Unit/Utils/MediaTypesTest.php - - message: "#^Parameter \\#1 \\$mediaType of static method Orisai\\\\OpenAPI\\\\Utils\\\\MediaTypes\\:\\:format\\(\\) expects non\\-empty\\-string, string given\\.$#" count: 1 diff --git a/tools/phpstan.neon b/tools/phpstan.neon index 8437767..1fd2377 100644 --- a/tools/phpstan.neon +++ b/tools/phpstan.neon @@ -3,7 +3,7 @@ includes: - phpstan.baseline.neon parameters: - phpVersion: 70400 + phpVersion: 80300 level: 8 tmpDir: ../var/tools/PHPStan resultCachePath: %currentWorkingDirectory%/var/tools/PHPStan/resultCache.php @@ -12,6 +12,8 @@ parameters: checkMissingCallableSignature: true checkInternalClassCaseSensitivity: true checkTooWideReturnTypesInProtectedAndPublicMethods: true + reportAnyTypeWideningInVarTag: true + reportPossiblyNonexistentConstantArrayOffset: true exceptions: check: