From fca08349c27978d3dc87543502fadf08ed93cd7d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 29 Dec 2022 17:48:39 +0100 Subject: [PATCH 01/29] Utilize `null`-default return to simplify extensions --- ...CommandGetHelperDynamicReturnTypeExtension.php | 12 +++++------- ...rfaceGetArgumentDynamicReturnTypeExtension.php | 13 +++++-------- ...terfaceGetOptionDynamicReturnTypeExtension.php | 13 +++++-------- ...erfaceGetOptionsDynamicReturnTypeExtension.php | 8 +++----- ...rfaceHasArgumentDynamicReturnTypeExtension.php | 15 ++++++--------- ...terfaceHasOptionDynamicReturnTypeExtension.php | 15 ++++++--------- 6 files changed, 30 insertions(+), 46 deletions(-) diff --git a/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php b/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php index db2348e3..3b38258c 100644 --- a/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/CommandGetHelperDynamicReturnTypeExtension.php @@ -36,22 +36,20 @@ public function isMethodSupported(MethodReflection $methodReflection): bool return $methodReflection->getName() === 'getHelper'; } - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type { - $defaultReturnType = new ObjectType('Symfony\Component\Console\Helper\HelperInterface'); - if (!isset($methodCall->getArgs()[0])) { - return $defaultReturnType; + return null; } $classReflection = $scope->getClassReflection(); if ($classReflection === null) { - return $defaultReturnType; + return null; } $argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value)); if (count($argStrings) !== 1) { - return $defaultReturnType; + return null; } $argName = $argStrings[0]->getValue(); @@ -65,7 +63,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } } - return count($returnTypes) > 0 ? TypeCombinator::union(...$returnTypes) : $defaultReturnType; + return count($returnTypes) > 0 ? TypeCombinator::union(...$returnTypes) : null; } } diff --git a/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php index a8c35200..0af7c88d 100644 --- a/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceGetArgumentDynamicReturnTypeExtension.php @@ -6,7 +6,6 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; -use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\ArrayType; use PHPStan\Type\DynamicMethodReturnTypeExtension; @@ -38,22 +37,20 @@ public function isMethodSupported(MethodReflection $methodReflection): bool return $methodReflection->getName() === 'getArgument'; } - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type { - $defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants())->getReturnType(); - if (!isset($methodCall->getArgs()[0])) { - return $defaultReturnType; + return null; } $classReflection = $scope->getClassReflection(); if ($classReflection === null) { - return $defaultReturnType; + return null; } $argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value)); if (count($argStrings) !== 1) { - return $defaultReturnType; + return null; } $argName = $argStrings[0]->getValue(); @@ -79,7 +76,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } } - return count($argTypes) > 0 ? TypeCombinator::union(...$argTypes) : $defaultReturnType; + return count($argTypes) > 0 ? TypeCombinator::union(...$argTypes) : null; } } diff --git a/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php index ad2bc6c6..d765f65b 100644 --- a/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php @@ -6,7 +6,6 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; -use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Type; @@ -39,22 +38,20 @@ public function isMethodSupported(MethodReflection $methodReflection): bool return $methodReflection->getName() === 'getOption'; } - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type { - $defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants())->getReturnType(); - if (!isset($methodCall->getArgs()[0])) { - return $defaultReturnType; + return null; } $classReflection = $scope->getClassReflection(); if ($classReflection === null) { - return $defaultReturnType; + return null; } $optStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value)); if (count($optStrings) !== 1) { - return $defaultReturnType; + return null; } $optName = $optStrings[0]->getValue(); @@ -69,7 +66,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } } - return count($optTypes) > 0 ? TypeCombinator::union(...$optTypes) : $defaultReturnType; + return count($optTypes) > 0 ? TypeCombinator::union(...$optTypes) : null; } } diff --git a/src/Type/Symfony/InputInterfaceGetOptionsDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceGetOptionsDynamicReturnTypeExtension.php index 80c6d4e2..515c44d0 100644 --- a/src/Type/Symfony/InputInterfaceGetOptionsDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceGetOptionsDynamicReturnTypeExtension.php @@ -6,7 +6,6 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; -use PHPStan\Reflection\ParametersAcceptorSelector; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\Constant\ConstantArrayTypeBuilder; use PHPStan\Type\Constant\ConstantStringType; @@ -40,12 +39,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool return $methodReflection->getName() === 'getOptions'; } - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type { - $defaultReturnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants())->getReturnType(); $classReflection = $scope->getClassReflection(); if ($classReflection === null) { - return $defaultReturnType; + return null; } $optTypes = []; @@ -65,7 +63,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } } - return count($optTypes) > 0 ? TypeCombinator::union(...$optTypes) : $defaultReturnType; + return count($optTypes) > 0 ? TypeCombinator::union(...$optTypes) : null; } } diff --git a/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php index dc933e14..4ce49c4a 100644 --- a/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceHasArgumentDynamicReturnTypeExtension.php @@ -7,7 +7,6 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; use PHPStan\Symfony\ConsoleApplicationResolver; -use PHPStan\Type\BooleanType; use PHPStan\Type\Constant\ConstantBooleanType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Type; @@ -36,22 +35,20 @@ public function isMethodSupported(MethodReflection $methodReflection): bool return $methodReflection->getName() === 'hasArgument'; } - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type { - $defaultReturnType = new BooleanType(); - if (!isset($methodCall->getArgs()[0])) { - return $defaultReturnType; + return null; } $classReflection = $scope->getClassReflection(); if ($classReflection === null) { - return $defaultReturnType; + return null; } $argStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value)); if (count($argStrings) !== 1) { - return $defaultReturnType; + return null; } $argName = $argStrings[0]->getValue(); @@ -67,11 +64,11 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } if (count($returnTypes) === 0) { - return $defaultReturnType; + return null; } $returnTypes = array_unique($returnTypes); - return count($returnTypes) === 1 ? new ConstantBooleanType($returnTypes[0]) : $defaultReturnType; + return count($returnTypes) === 1 ? new ConstantBooleanType($returnTypes[0]) : null; } } diff --git a/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php b/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php index 3f239fe6..3be621f8 100644 --- a/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/InputInterfaceHasOptionDynamicReturnTypeExtension.php @@ -7,7 +7,6 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; use PHPStan\Symfony\ConsoleApplicationResolver; -use PHPStan\Type\BooleanType; use PHPStan\Type\Constant\ConstantBooleanType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Type; @@ -36,22 +35,20 @@ public function isMethodSupported(MethodReflection $methodReflection): bool return $methodReflection->getName() === 'hasOption'; } - public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type + public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): ?Type { - $defaultReturnType = new BooleanType(); - if (!isset($methodCall->getArgs()[0])) { - return $defaultReturnType; + return null; } $classReflection = $scope->getClassReflection(); if ($classReflection === null) { - return $defaultReturnType; + return null; } $optStrings = TypeUtils::getConstantStrings($scope->getType($methodCall->getArgs()[0]->value)); if (count($optStrings) !== 1) { - return $defaultReturnType; + return null; } $optName = $optStrings[0]->getValue(); @@ -67,11 +64,11 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } if (count($returnTypes) === 0) { - return $defaultReturnType; + return null; } $returnTypes = array_unique($returnTypes); - return count($returnTypes) === 1 ? new ConstantBooleanType($returnTypes[0]) : $defaultReturnType; + return count($returnTypes) === 1 ? new ConstantBooleanType($returnTypes[0]) : null; } } From d89a521e7e31822409bf37f70691f7a12a6e7d76 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 14 Jan 2023 23:21:38 +0100 Subject: [PATCH 02/29] Revert wrong typehint for getSession --- stubs/Symfony/Component/HttpFoundation/Request.stub | 5 ----- tests/Type/Symfony/data/request_get_session.php | 6 +++--- tests/Type/Symfony/data/request_get_session_null.php | 6 +++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/stubs/Symfony/Component/HttpFoundation/Request.stub b/stubs/Symfony/Component/HttpFoundation/Request.stub index 861769df..0c2140cc 100644 --- a/stubs/Symfony/Component/HttpFoundation/Request.stub +++ b/stubs/Symfony/Component/HttpFoundation/Request.stub @@ -26,11 +26,6 @@ class Request */ public $cookies; - /** - * @return \Symfony\Component\HttpFoundation\Session\Session - */ - public function getSession(); - /** * @return string[] */ diff --git a/tests/Type/Symfony/data/request_get_session.php b/tests/Type/Symfony/data/request_get_session.php index 17ef88a6..9a0335e5 100644 --- a/tests/Type/Symfony/data/request_get_session.php +++ b/tests/Type/Symfony/data/request_get_session.php @@ -1,14 +1,14 @@ getSession(); -assertType(Session::class, $request->getSession()); +assertType(SessionInterface::class, $request->getSession()); if ($request->hasSession()) { - assertType(Session::class, $request->getSession()); + assertType(SessionInterface::class, $request->getSession()); } diff --git a/tests/Type/Symfony/data/request_get_session_null.php b/tests/Type/Symfony/data/request_get_session_null.php index be0fd0d1..9c37979d 100644 --- a/tests/Type/Symfony/data/request_get_session_null.php +++ b/tests/Type/Symfony/data/request_get_session_null.php @@ -1,14 +1,14 @@ getSession(); -assertType(Session::class . '|null', $request->getSession()); +assertType(SessionInterface::class . '|null', $request->getSession()); if ($request->hasSession()) { - assertType(Session::class, $request->getSession()); + assertType(SessionInterface::class, $request->getSession()); } From 44aef787a1062d2eec7932e958f0fbe6b2a22a67 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 31 Jan 2023 16:20:29 +0100 Subject: [PATCH 03/29] Introduce Voter stub --- extension.neon | 2 ++ .../Core/Authorization/Voter/Voter.stub | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub diff --git a/extension.neon b/extension.neon index 582126af..e0c53ba0 100644 --- a/extension.neon +++ b/extension.neon @@ -14,6 +14,7 @@ parameters: featureToggles: skipCheckGenericClasses: - Symfony\Component\OptionsResolver\Options + - Symfony\Component\Security\Core\Authorization\Voter\Voter - Symfony\Component\Security\Core\User\PasswordUpgraderInterface stubFiles: - stubs/Psr/Cache/CacheItemInterface.stub @@ -50,6 +51,7 @@ parameters: - stubs/Symfony/Component/Security/Acl/Model/AclInterface.stub - stubs/Symfony/Component/Security/Acl/Model/EntryInterface.stub - stubs/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.stub + - stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub - stubs/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.stub - stubs/Symfony/Component/Security/Core/User/PasswordAuthenticatedUserInterface.stub - stubs/Symfony/Component/Security/Core/User/PasswordUpgraderInterface.stub diff --git a/stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub b/stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub new file mode 100644 index 00000000..17485a28 --- /dev/null +++ b/stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub @@ -0,0 +1,35 @@ + Date: Tue, 31 Jan 2023 16:32:08 +0100 Subject: [PATCH 04/29] Fix build --- .../Symfony/InvalidArgumentDefaultValueRule.php | 2 +- src/Rules/Symfony/InvalidOptionDefaultValueRule.php | 2 +- src/Type/Symfony/EnvelopeReturnTypeExtension.php | 11 ++++++++--- .../Symfony/SerializerDynamicReturnTypeExtension.php | 12 ++++++++---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php index 51d7c3bc..e48f8718 100644 --- a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php @@ -46,7 +46,7 @@ public function processNode(Node $node, Scope $scope): array } $modeType = isset($node->getArgs()[1]) ? $scope->getType($node->getArgs()[1]->value) : new NullType(); - if ($modeType instanceof NullType) { + if ($modeType->isNull()->yes()) { $modeType = new ConstantIntegerType(2); // InputArgument::OPTIONAL } $modeTypes = TypeUtils::getConstantScalars($modeType); diff --git a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php index ab52d626..171f94f1 100644 --- a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php @@ -48,7 +48,7 @@ public function processNode(Node $node, Scope $scope): array } $modeType = isset($node->getArgs()[2]) ? $scope->getType($node->getArgs()[2]->value) : new NullType(); - if ($modeType instanceof NullType) { + if ($modeType->isNull()->yes()) { $modeType = new ConstantIntegerType(1); // InputOption::VALUE_NONE } $modeTypes = TypeUtils::getConstantScalars($modeType); diff --git a/src/Type/Symfony/EnvelopeReturnTypeExtension.php b/src/Type/Symfony/EnvelopeReturnTypeExtension.php index ec2531aa..2e01dec7 100644 --- a/src/Type/Symfony/EnvelopeReturnTypeExtension.php +++ b/src/Type/Symfony/EnvelopeReturnTypeExtension.php @@ -7,12 +7,12 @@ use PHPStan\Reflection\MethodReflection; use PHPStan\Type\Accessory\AccessoryArrayListType; use PHPStan\Type\ArrayType; -use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\Generic\GenericClassStringType; use PHPStan\Type\IntegerType; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; +use PHPStan\Type\TypeCombinator; use function count; final class EnvelopeReturnTypeExtension implements DynamicMethodReturnTypeExtension @@ -42,11 +42,16 @@ public function getTypeFromMethodCall( } $argType = $scope->getType($methodCall->getArgs()[0]->value); - if (!$argType instanceof ConstantStringType) { + if (count($argType->getConstantStrings()) === 0) { return AccessoryArrayListType::intersectWith(new ArrayType(new IntegerType(), new ObjectType('Symfony\Component\Messenger\Stamp\StampInterface'))); } - return AccessoryArrayListType::intersectWith(new ArrayType(new IntegerType(), new ObjectType($argType->getValue()))); + $objectTypes = []; + foreach ($argType->getConstantStrings() as $constantString) { + $objectTypes[] = new ObjectType($constantString->getValue()); + } + + return AccessoryArrayListType::intersectWith(new ArrayType(new IntegerType(), TypeCombinator::union(...$objectTypes))); } } diff --git a/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php b/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php index 5525a770..d3ea959d 100755 --- a/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/SerializerDynamicReturnTypeExtension.php @@ -6,11 +6,12 @@ use PHPStan\Analyser\Scope; use PHPStan\Reflection\MethodReflection; use PHPStan\Type\ArrayType; -use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\MixedType; use PHPStan\Type\ObjectType; use PHPStan\Type\Type; +use PHPStan\Type\TypeCombinator; +use function count; use function substr; class SerializerDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension @@ -45,13 +46,16 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } $argType = $scope->getType($methodCall->getArgs()[1]->value); - if (!$argType instanceof ConstantStringType) { + if (count($argType->getConstantStrings()) === 0) { return new MixedType(); } - $objectName = $argType->getValue(); + $types = []; + foreach ($argType->getConstantStrings() as $constantString) { + $types[] = $this->getType($constantString->getValue()); + } - return $this->getType($objectName); + return TypeCombinator::union(...$types); } private function getType(string $objectName): Type From d0151d06555e446634c7b8175d1feb292b102085 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Tue, 31 Jan 2023 16:41:53 +0100 Subject: [PATCH 05/29] Bump minimum PHPStan version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index adc7050a..465f7050 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "php": "^7.2 || ^8.0", "ext-simplexml": "*", - "phpstan/phpstan": "^1.9.1" + "phpstan/phpstan": "^1.9.4" }, "conflict": { "symfony/framework-bundle": "<3.0" From 2107deec9d95c0e7fbba35fe4d34287342878ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C5=82odarczyk?= Date: Tue, 31 Jan 2023 19:10:01 +0100 Subject: [PATCH 06/29] Add ArrayObject to NormalizerInterface::normalize() return type. --- .../Component/Serializer/Normalizer/NormalizerInterface.stub | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub b/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub index a65b5bed..8fc966ad 100644 --- a/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub +++ b/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub @@ -2,13 +2,16 @@ namespace Symfony\Component\Serializer\Normalizer; +use ArrayObject; + interface NormalizerInterface { /** * @param mixed $object * @param string|null $format * @param array $context - * @return array|string|int|float|bool|null + * + * @return array|ArrayObject|string|int|float|bool|null */ public function normalize($object, $format = null, array $context = []); From cbf5b9ceadab8365ed46db42dcd23db1a4c26c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C5=82odarczyk?= Date: Tue, 31 Jan 2023 19:23:00 +0100 Subject: [PATCH 07/29] Add @throws annotations in DenormalizerInterface::denormalize() and NormalizerInterface::normalize(). --- extension.neon | 8 ++++++++ .../Exception/BadMethodCallException.stub | 7 +++++++ .../Exception/CircularReferenceException.stub | 7 +++++++ .../Exception/ExceptionInterface.stub | 7 +++++++ .../Exception/ExtraAttributesException.stub | 20 +++++++++++++++++++ .../Exception/InvalidArgumentException.stub | 7 +++++++ .../Serializer/Exception/LogicException.stub | 7 +++++++ .../Exception/RuntimeException.stub | 7 +++++++ .../Exception/UnexpectedValueException.stub | 7 +++++++ .../Normalizer/DenormalizerInterface.stub | 16 +++++++++++++++ .../Normalizer/NormalizerInterface.stub | 9 +++++++++ 11 files changed, 102 insertions(+) create mode 100644 stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/CircularReferenceException.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/ExceptionInterface.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/ExtraAttributesException.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/InvalidArgumentException.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/LogicException.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/RuntimeException.stub create mode 100644 stubs/Symfony/Component/Serializer/Exception/UnexpectedValueException.stub diff --git a/extension.neon b/extension.neon index e0c53ba0..42ae87ba 100644 --- a/extension.neon +++ b/extension.neon @@ -58,6 +58,14 @@ parameters: - stubs/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.stub - stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub - stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub + - stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub + - stubs/Symfony/Component/Serializer/Exception/CircularReferenceException.stub + - stubs/Symfony/Component/Serializer/Exception/ExceptionInterface.stub + - stubs/Symfony/Component/Serializer/Exception/ExtraAttributesException.stub + - stubs/Symfony/Component/Serializer/Exception/InvalidArgumentException.stub + - stubs/Symfony/Component/Serializer/Exception/LogicException.stub + - stubs/Symfony/Component/Serializer/Exception/RuntimeException.stub + - stubs/Symfony/Component/Serializer/Exception/UnexpectedValueException.stub - stubs/Symfony/Component/Serializer/Normalizer/ContextAwareDenormalizerInterface.stub - stubs/Symfony/Component/Serializer/Normalizer/ContextAwareNormalizerInterface.stub - stubs/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.stub diff --git a/stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub b/stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub new file mode 100644 index 00000000..3c569971 --- /dev/null +++ b/stubs/Symfony/Component/Serializer/Exception/BadMethodCallException.stub @@ -0,0 +1,7 @@ + $context * @return mixed + * + * @throws BadMethodCallException + * @throws InvalidArgumentException + * @throws UnexpectedValueException + * @throws ExtraAttributesException + * @throws LogicException + * @throws RuntimeException + * @throws ExceptionInterface */ public function denormalize($data, $type, $format = null, array $context = []); diff --git a/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub b/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub index 8fc966ad..fac60042 100644 --- a/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub +++ b/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub @@ -3,6 +3,10 @@ namespace Symfony\Component\Serializer\Normalizer; use ArrayObject; +use Symfony\Component\Serializer\Exception\CircularReferenceException; +use Symfony\Component\Serializer\Exception\ExceptionInterface; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; +use Symfony\Component\Serializer\Exception\LogicException; interface NormalizerInterface { @@ -12,6 +16,11 @@ interface NormalizerInterface * @param array $context * * @return array|ArrayObject|string|int|float|bool|null + * + * @throws InvalidArgumentException + * @throws CircularReferenceException + * @throws LogicException + * @throws ExceptionInterface */ public function normalize($object, $format = null, array $context = []); From 8a8d0538ca943b20beda7e9799e14fb3683262d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=C5=82odarczyk?= Date: Sat, 4 Feb 2023 09:56:44 +0100 Subject: [PATCH 08/29] Add missing @throws in stubs. --- extension.neon | 5 +++++ stubs/Psr/Cache/CacheException.stub | 7 +++++++ stubs/Psr/Cache/InvalidArgumentException.stub | 7 +++++++ stubs/Symfony/Component/Console/Command.stub | 6 ++++++ .../Component/Console/Exception/ExceptionInterface.stub | 7 +++++++ .../Console/Exception/InvalidArgumentException.stub | 7 +++++++ .../Component/Console/Exception/LogicException.stub | 7 +++++++ .../DependencyInjection/Extension/ExtensionInterface.stub | 2 ++ .../Component/Serializer/Encoder/DecoderInterface.stub | 2 ++ .../Component/Serializer/Encoder/EncoderInterface.stub | 4 ++++ stubs/Symfony/Contracts/Cache/CacheInterface.stub | 4 ++++ 11 files changed, 58 insertions(+) create mode 100644 stubs/Psr/Cache/CacheException.stub create mode 100644 stubs/Psr/Cache/InvalidArgumentException.stub create mode 100644 stubs/Symfony/Component/Console/Exception/ExceptionInterface.stub create mode 100644 stubs/Symfony/Component/Console/Exception/InvalidArgumentException.stub create mode 100644 stubs/Symfony/Component/Console/Exception/LogicException.stub diff --git a/extension.neon b/extension.neon index 42ae87ba..e4880077 100644 --- a/extension.neon +++ b/extension.neon @@ -17,11 +17,16 @@ parameters: - Symfony\Component\Security\Core\Authorization\Voter\Voter - Symfony\Component\Security\Core\User\PasswordUpgraderInterface stubFiles: + - stubs/Psr/Cache/CacheException.stub - stubs/Psr/Cache/CacheItemInterface.stub + - stubs/Psr/Cache/InvalidArgumentException.stub - stubs/Symfony/Bundle/FrameworkBundle/KernelBrowser.stub - stubs/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.stub - stubs/Symfony/Bundle/FrameworkBundle/Test/TestContainer.stub - stubs/Symfony/Component/Console/Command.stub + - stubs/Symfony/Component/Console/Exception/ExceptionInterface.stub + - stubs/Symfony/Component/Console/Exception/InvalidArgumentException.stub + - stubs/Symfony/Component/Console/Exception/LogicException.stub - stubs/Symfony/Component/Console/Helper/HelperInterface.stub - stubs/Symfony/Component/Console/Output/OutputInterface.stub - stubs/Symfony/Component/DependencyInjection/ContainerBuilder.stub diff --git a/stubs/Psr/Cache/CacheException.stub b/stubs/Psr/Cache/CacheException.stub new file mode 100644 index 00000000..1be3e49b --- /dev/null +++ b/stubs/Psr/Cache/CacheException.stub @@ -0,0 +1,7 @@ + $configs + * + * @throws \InvalidArgumentException */ public function load(array $configs, ContainerBuilder $container): void; } diff --git a/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub b/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub index 715dadc4..a9923edf 100644 --- a/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub +++ b/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub @@ -11,6 +11,8 @@ interface DecoderInterface * @param string $format * @param array $context * @return mixed + * + * @throws UnexpectedValueException */ public function decode($data, $format, array $context = []); diff --git a/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub b/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub index eb6fc97c..2d97bde3 100644 --- a/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub +++ b/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub @@ -2,6 +2,8 @@ namespace Symfony\Component\Serializer\Encoder; +use Symfony\Component\Serializer\Exception\UnexpectedValueException; + interface EncoderInterface { /** @@ -9,6 +11,8 @@ interface EncoderInterface * @param string $format * @param array $context * @return string + * + * @throws UnexpectedValueException */ public function encode($data, $format, array $context = []); diff --git a/stubs/Symfony/Contracts/Cache/CacheInterface.stub b/stubs/Symfony/Contracts/Cache/CacheInterface.stub index f4cc208d..ff3027b1 100644 --- a/stubs/Symfony/Contracts/Cache/CacheInterface.stub +++ b/stubs/Symfony/Contracts/Cache/CacheInterface.stub @@ -2,6 +2,8 @@ namespace Symfony\Contracts\Cache; +use Psr\Cache\InvalidArgumentException; + interface CacheInterface { /** @@ -10,6 +12,8 @@ interface CacheInterface * @param \Symfony\Contracts\Cache\CallbackInterface|callable(\Symfony\Contracts\Cache\ItemInterface, bool): T $callback * @param array $metadata * @return T + * + * @throws InvalidArgumentException */ public function get(string $key, callable $callback, float $beta = null, array &$metadata = null); } From 58e64ffc912c984f448e5ed800ca6c8ce343a0e9 Mon Sep 17 00:00:00 2001 From: jmleroux Date: Wed, 15 Feb 2023 05:55:06 +0100 Subject: [PATCH 09/29] Add PHPUnit compatibility for PHP 7.2 --- .github/workflows/build.yml | 12 ------------ composer.json | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1045f11c..96765433 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,10 +33,6 @@ jobs: coverage: "none" php-version: "${{ matrix.php-version }}" - - name: "Downgrade PHPUnit" - if: matrix.php-version == '7.2' - run: "composer require --dev phpunit/phpunit:^8.5.29 --no-update --update-with-dependencies" - - name: "Validate Composer" run: "composer validate" @@ -101,10 +97,6 @@ jobs: coverage: "none" php-version: "${{ matrix.php-version }}" - - name: "Downgrade PHPUnit" - if: matrix.php-version == '7.2' - run: "composer require --dev phpunit/phpunit:^8.5.29 --no-update --update-with-dependencies" - - name: "Install lowest dependencies" if: ${{ matrix.dependencies == 'lowest' }} run: "composer update --prefer-lowest --no-interaction --no-progress" @@ -146,10 +138,6 @@ jobs: extensions: mbstring tools: composer:v2 - - name: "Downgrade PHPUnit" - if: matrix.php-version == '7.2' - run: "composer require --dev phpunit/phpunit:^8.5.29 --no-update --update-with-dependencies" - - name: "Install lowest dependencies" if: ${{ matrix.dependencies == 'lowest' }} run: "composer update --prefer-lowest --no-interaction --no-progress" diff --git a/composer.json b/composer.json index 465f7050..9f8c6569 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan-phpunit": "^1.0", "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^8.5.29 || ^9.5", "psr/container": "1.0 || 1.1.1", "symfony/config": "^5.4 || ^6.1", "symfony/console": "^5.4 || ^6.1", From 2f363239357b849bc150295b554100c106b6c26b Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 8 Mar 2023 17:31:10 +0100 Subject: [PATCH 10/29] Fix build --- src/Type/Symfony/ParameterDynamicReturnTypeExtension.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php b/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php index b160ddc8..82d3599e 100644 --- a/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php +++ b/src/Type/Symfony/ParameterDynamicReturnTypeExtension.php @@ -14,7 +14,6 @@ use PHPStan\Type\BooleanType; use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantBooleanType; -use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\ConstantType; use PHPStan\Type\DynamicMethodReturnTypeExtension; use PHPStan\Type\FloatType; @@ -160,9 +159,12 @@ private function generalizeTypeFromValue(Scope $scope, $value): Type $keyTypes = []; $valueTypes = []; foreach ($value as $key => $element) { - /** @var ConstantStringType $keyType */ $keyType = $scope->getTypeFromValue($key); - $keyTypes[] = $keyType; + $keyStringTypes = $keyType->getConstantStrings(); + if (count($keyStringTypes) !== 1) { + throw new ShouldNotHappenException(); + } + $keyTypes[] = $keyStringTypes[0]; $valueTypes[] = $this->generalizeTypeFromValue($scope, $element); } From d7425ae62493f0462e6d3aa18cba8b90dea897f1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 02:31:07 +0000 Subject: [PATCH 11/29] Update metcalfc/changelog-generator action to v4.1.0 --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bac4a006..92b72547 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - name: Generate changelog id: changelog - uses: metcalfc/changelog-generator@v4.0.1 + uses: metcalfc/changelog-generator@v4.1.0 with: myToken: ${{ secrets.PHPSTAN_BOT_TOKEN }} From e0823d3daf5220ea2a07751ddffa3ad0882bdfe8 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 22 Mar 2023 09:34:23 +0100 Subject: [PATCH 12/29] Update PHPCS --- build-cs/composer.json | 7 +-- build-cs/composer.lock | 117 ++++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 57 deletions(-) diff --git a/build-cs/composer.json b/build-cs/composer.json index e3079710..16a240bc 100644 --- a/build-cs/composer.json +++ b/build-cs/composer.json @@ -1,8 +1,9 @@ { "require-dev": { - "consistence-community/coding-standard": "^3.10", - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "slevomat/coding-standard": "^7.0" + "consistence-community/coding-standard": "^3.11.0", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", + "slevomat/coding-standard": "^8.8.0", + "squizlabs/php_codesniffer": "^3.5.3" }, "config": { "allow-plugins": { diff --git a/build-cs/composer.lock b/build-cs/composer.lock index 4bcc8de4..c25a151a 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -4,35 +4,35 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4485bbedba7bcc71ace5f69dbb9b6c47", + "content-hash": "e69c1916405a7e3c8001c1b609a0ee61", "packages": [], "packages-dev": [ { "name": "consistence-community/coding-standard", - "version": "3.11.1", + "version": "3.11.2", "source": { "type": "git", "url": "https://github.com/consistence-community/coding-standard.git", - "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df" + "reference": "adb4be482e76990552bf624309d2acc8754ba1bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/4632fead8c9ee8f50044fcbce9f66c797b34c0df", - "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df", + "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/adb4be482e76990552bf624309d2acc8754ba1bd", + "reference": "adb4be482e76990552bf624309d2acc8754ba1bd", "shasum": "" }, "require": { - "php": ">=7.4", - "slevomat/coding-standard": "~7.0", - "squizlabs/php_codesniffer": "~3.6.0" + "php": "~8.0", + "slevomat/coding-standard": "~8.0", + "squizlabs/php_codesniffer": "~3.7.0" }, "replace": { "consistence/coding-standard": "3.10.*" }, "require-dev": { - "phing/phing": "2.16.4", - "php-parallel-lint/php-parallel-lint": "1.3.0", - "phpunit/phpunit": "9.5.4" + "phing/phing": "2.17.0", + "php-parallel-lint/php-parallel-lint": "1.3.1", + "phpunit/phpunit": "9.5.10" }, "type": "library", "autoload": { @@ -70,41 +70,44 @@ ], "support": { "issues": "https://github.com/consistence-community/coding-standard/issues", - "source": "https://github.com/consistence-community/coding-standard/tree/3.11.1" + "source": "https://github.com/consistence-community/coding-standard/tree/3.11.2" }, - "time": "2021-05-03T18:13:22+00:00" + "time": "2022-06-21T08:36:36+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -120,7 +123,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -144,23 +147,23 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.5.1", + "version": "1.15.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "981cc368a216c988e862a75e526b6076987d1b50" + "reference": "61800f71a5526081d1b5633766aa88341f1ade76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", - "reference": "981cc368a216c988e862a75e526b6076987d1b50", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/61800f71a5526081d1b5633766aa88341f1ade76", + "reference": "61800f71a5526081d1b5633766aa88341f1ade76", "shasum": "" }, "require": { @@ -170,6 +173,7 @@ "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", "phpstan/phpstan-strict-rules": "^1.0", "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" @@ -189,43 +193,43 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.15.3" }, - "time": "2022-05-05T11:32:40+00:00" + "time": "2022-12-20T20:56:55+00:00" }, { "name": "slevomat/coding-standard", - "version": "7.2.1", + "version": "8.8.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + "reference": "59e25146a4ef0a7b194c5bc55b32dd414345db89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/59e25146a4ef0a7b194c5bc55b32dd414345db89", + "reference": "59e25146a4ef0a7b194c5bc55b32dd414345db89", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.5.1", - "squizlabs/php_codesniffer": "^3.6.2" + "phpstan/phpdoc-parser": ">=1.15.2 <1.16.0", + "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { - "phing/phing": "2.17.3", + "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.7.1", - "phpstan/phpstan-deprecation-rules": "1.0.0", - "phpstan/phpstan-phpunit": "1.0.0|1.1.1", - "phpstan/phpstan-strict-rules": "1.2.3", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + "phpstan/phpstan": "1.4.10|1.9.6", + "phpstan/phpstan-deprecation-rules": "1.1.1", + "phpstan/phpstan-phpunit": "1.0.0|1.3.3", + "phpstan/phpstan-strict-rules": "1.4.4", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.27" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "7.x-dev" + "dev-master": "8.x-dev" } }, "autoload": { @@ -238,9 +242,13 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "keywords": [ + "dev", + "phpcs" + ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.8.0" }, "funding": [ { @@ -252,20 +260,20 @@ "type": "tidelift" } ], - "time": "2022-05-25T10:58:12+00:00" + "time": "2023-01-09T10:46:13+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.2", + "version": "3.7.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", - "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, "require": { @@ -301,14 +309,15 @@ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-12-12T21:44:58+00:00" + "time": "2023-02-22T23:07:41+00:00" } ], "aliases": [], From db81b1861aac7cc2e66115cb33b4d1ea2a73d096 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Thu, 30 Mar 2023 10:38:10 +0200 Subject: [PATCH 13/29] Use stubfile extension for PasswordUpgraderInterface --- composer.json | 2 +- extension.neon | 6 ++-- src/Symfony/InputBagStubFilesExtension.php | 17 +++++++-- ...ordAuthenticatedUserStubFilesExtension.php | 36 +++++++++++++++++++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 src/Symfony/PasswordAuthenticatedUserStubFilesExtension.php diff --git a/composer.json b/composer.json index 9f8c6569..22501953 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "php": "^7.2 || ^8.0", "ext-simplexml": "*", - "phpstan/phpstan": "^1.9.4" + "phpstan/phpstan": "^1.9.18" }, "conflict": { "symfony/framework-bundle": "<3.0" diff --git a/extension.neon b/extension.neon index e4880077..1a8cf313 100644 --- a/extension.neon +++ b/extension.neon @@ -58,8 +58,6 @@ parameters: - stubs/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.stub - stubs/Symfony/Component/Security/Core/Authorization/Voter/Voter.stub - stubs/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.stub - - stubs/Symfony/Component/Security/Core/User/PasswordAuthenticatedUserInterface.stub - - stubs/Symfony/Component/Security/Core/User/PasswordUpgraderInterface.stub - stubs/Symfony/Component/Serializer/Encoder/ContextAwareDecoderInterface.stub - stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub - stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub @@ -298,6 +296,10 @@ services: class: PHPStan\Symfony\InputBagStubFilesExtension tags: - phpstan.stubFilesExtension + - + class: PHPStan\Symfony\PasswordAuthenticatedUserStubFilesExtension + tags: + - phpstan.stubFilesExtension # FormInterface::getErrors() return type - diff --git a/src/Symfony/InputBagStubFilesExtension.php b/src/Symfony/InputBagStubFilesExtension.php index 834ca228..140dae99 100644 --- a/src/Symfony/InputBagStubFilesExtension.php +++ b/src/Symfony/InputBagStubFilesExtension.php @@ -2,15 +2,28 @@ namespace PHPStan\Symfony; +use PHPStan\BetterReflection\Reflector\Exception\IdentifierNotFound; +use PHPStan\BetterReflection\Reflector\Reflector; use PHPStan\PhpDoc\StubFilesExtension; -use function class_exists; class InputBagStubFilesExtension implements StubFilesExtension { + /** @var Reflector */ + private $reflector; + + public function __construct( + Reflector $reflector + ) + { + $this->reflector = $reflector; + } + public function getFiles(): array { - if (!class_exists('Symfony\Component\HttpFoundation\InputBag')) { + try { + $this->reflector->reflectClass('Symfony\Component\HttpFoundation\InputBag'); + } catch (IdentifierNotFound $e) { return []; } diff --git a/src/Symfony/PasswordAuthenticatedUserStubFilesExtension.php b/src/Symfony/PasswordAuthenticatedUserStubFilesExtension.php new file mode 100644 index 00000000..8f8c4782 --- /dev/null +++ b/src/Symfony/PasswordAuthenticatedUserStubFilesExtension.php @@ -0,0 +1,36 @@ +reflector = $reflector; + } + + public function getFiles(): array + { + try { + $this->reflector->reflectClass('Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface'); + } catch (IdentifierNotFound $e) { + return []; + } + + return [ + __DIR__ . '/../../stubs/Symfony/Component/Security/Core/User/PasswordAuthenticatedUserInterface.stub', + __DIR__ . '/../../stubs/Symfony/Component/Security/Core/User/PasswordUpgraderInterface.stub', + ]; + } + +} From 1da7bf450c6b351fec08ca0aa97298473d4f6ab3 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Thu, 23 Mar 2023 14:44:33 +0100 Subject: [PATCH 14/29] Add stubs for security factories --- extension.neon | 2 ++ .../Factory/AuthenticatorFactoryInterface.stub | 16 ++++++++++++++++ .../FirewallListenerFactoryInterface.stub | 15 +++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.stub create mode 100644 stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FirewallListenerFactoryInterface.stub diff --git a/extension.neon b/extension.neon index 1a8cf313..1dfcca46 100644 --- a/extension.neon +++ b/extension.neon @@ -23,6 +23,8 @@ parameters: - stubs/Symfony/Bundle/FrameworkBundle/KernelBrowser.stub - stubs/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.stub - stubs/Symfony/Bundle/FrameworkBundle/Test/TestContainer.stub + - stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.stub + - stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FirewallListenerFactoryInterface.stub - stubs/Symfony/Component/Console/Command.stub - stubs/Symfony/Component/Console/Exception/ExceptionInterface.stub - stubs/Symfony/Component/Console/Exception/InvalidArgumentException.stub diff --git a/stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.stub b/stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.stub new file mode 100644 index 00000000..8ca4b331 --- /dev/null +++ b/stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AuthenticatorFactoryInterface.stub @@ -0,0 +1,16 @@ + $config + * + * @return string|string[] + */ + public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId); +} diff --git a/stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FirewallListenerFactoryInterface.stub b/stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FirewallListenerFactoryInterface.stub new file mode 100644 index 00000000..5c6b54fd --- /dev/null +++ b/stubs/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/FirewallListenerFactoryInterface.stub @@ -0,0 +1,15 @@ + $config + * + * @return string[] + */ + public function createListeners(ContainerBuilder $container, string $firewallName, array $config): array; +} From f45b9ceccfe81b6cd8229a8f9ad7060a8ee5cb30 Mon Sep 17 00:00:00 2001 From: Natsuki Ikeguchi Date: Fri, 14 Apr 2023 21:17:46 +0900 Subject: [PATCH 15/29] Support specifying type of data_class in forms --- extension.neon | 7 ++ .../Symfony/Component/Form/AbstractType.stub | 12 ++++ .../Component/Form/FormFactoryInterface.stub | 36 ++++++++++ .../Symfony/Component/Form/FormInterface.stub | 16 ++++- .../Form/FormTypeExtensionInterface.stub | 5 ++ .../Component/Form/FormTypeInterface.stub | 5 ++ .../Exception/InvalidOptionsException.stub | 7 ++ tests/Type/Symfony/ExtensionTest.php | 1 + tests/Type/Symfony/data/form_data_type.php | 72 +++++++++++++++++++ 9 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 stubs/Symfony/Component/Form/AbstractType.stub create mode 100644 stubs/Symfony/Component/Form/FormFactoryInterface.stub create mode 100644 stubs/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.stub create mode 100644 tests/Type/Symfony/data/form_data_type.php diff --git a/extension.neon b/extension.neon index 1dfcca46..40165b39 100644 --- a/extension.neon +++ b/extension.neon @@ -13,6 +13,10 @@ parameters: consoleApplicationLoader: null featureToggles: skipCheckGenericClasses: + - Symfony\Component\Form\AbstractType + - Symfony\Component\Form\FormInterface + - Symfony\Component\Form\FormTypeExtensionInterface + - Symfony\Component\Form\FormTypeInterface - Symfony\Component\OptionsResolver\Options - Symfony\Component\Security\Core\Authorization\Voter\Voter - Symfony\Component\Security\Core\User\PasswordUpgraderInterface @@ -36,6 +40,7 @@ parameters: - stubs/Symfony/Component/EventDispatcher/EventDispatcherInterface.stub - stubs/Symfony/Component/EventDispatcher/EventSubscriberInterface.stub - stubs/Symfony/Component/EventDispatcher/GenericEvent.stub + - stubs/Symfony/Component/Form/AbstractType.stub - stubs/Symfony/Component/Form/ChoiceList/Loader/ChoiceLoaderInterface.stub - stubs/Symfony/Component/Form/Exception/ExceptionInterface.stub - stubs/Symfony/Component/Form/Exception/RuntimeException.stub @@ -43,6 +48,7 @@ parameters: - stubs/Symfony/Component/Form/DataTransformerInterface.stub - stubs/Symfony/Component/Form/FormBuilderInterface.stub - stubs/Symfony/Component/Form/FormInterface.stub + - stubs/Symfony/Component/Form/FormFactoryInterface.stub - stubs/Symfony/Component/Form/FormTypeExtensionInterface.stub - stubs/Symfony/Component/Form/FormTypeInterface.stub - stubs/Symfony/Component/Form/FormView.stub @@ -52,6 +58,7 @@ parameters: - stubs/Symfony/Component/HttpFoundation/Session.stub - stubs/Symfony/Component/Messenger/StampInterface.stub - stubs/Symfony/Component/Messenger/Envelope.stub + - stubs/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.stub - stubs/Symfony/Component/OptionsResolver/Options.stub - stubs/Symfony/Component/Process/Process.stub - stubs/Symfony/Component/PropertyAccess/PropertyPathInterface.stub diff --git a/stubs/Symfony/Component/Form/AbstractType.stub b/stubs/Symfony/Component/Form/AbstractType.stub new file mode 100644 index 00000000..76170a02 --- /dev/null +++ b/stubs/Symfony/Component/Form/AbstractType.stub @@ -0,0 +1,12 @@ + + */ +abstract class AbstractType implements FormTypeInterface +{ +} diff --git a/stubs/Symfony/Component/Form/FormFactoryInterface.stub b/stubs/Symfony/Component/Form/FormFactoryInterface.stub new file mode 100644 index 00000000..a2221ec0 --- /dev/null +++ b/stubs/Symfony/Component/Form/FormFactoryInterface.stub @@ -0,0 +1,36 @@ + + * @template TData + * + * @param class-string $type + * @param TData $data + * @param array $options + * + * @phpstan-return ($data is null ? FormInterface : FormInterface) + * + * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function create(string $type = FormType::class, $data = null, array $options = []): FormInterface; + + /** + * @template TFormType of FormTypeInterface + * @template TData + * + * @param class-string $type + * @param TData $data + * @param array $options + * + * @phpstan-return ($data is null ? FormInterface : FormInterface) + * + * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function createNamed(string $name, string $type = FormType::class, $data = null, array $options = []): FormInterface; +} diff --git a/stubs/Symfony/Component/Form/FormInterface.stub b/stubs/Symfony/Component/Form/FormInterface.stub index 6960cce5..4bd21229 100644 --- a/stubs/Symfony/Component/Form/FormInterface.stub +++ b/stubs/Symfony/Component/Form/FormInterface.stub @@ -3,10 +3,22 @@ namespace Symfony\Component\Form; /** - * @extends \ArrayAccess - * @extends \Traversable + * @template TData + * + * @extends \ArrayAccess> + * @extends \Traversable> */ interface FormInterface extends \ArrayAccess, \Traversable, \Countable { + /** + * @param TData $modelData + * + * @return $this + */ + public function setData($modelData): FormInterface; + /** + * @return TData + */ + public function getData(); } diff --git a/stubs/Symfony/Component/Form/FormTypeExtensionInterface.stub b/stubs/Symfony/Component/Form/FormTypeExtensionInterface.stub index 25b6f25d..234d1b2e 100644 --- a/stubs/Symfony/Component/Form/FormTypeExtensionInterface.stub +++ b/stubs/Symfony/Component/Form/FormTypeExtensionInterface.stub @@ -2,6 +2,9 @@ namespace Symfony\Component\Form; +/** + * @template TData + */ interface FormTypeExtensionInterface { /** @@ -10,11 +13,13 @@ interface FormTypeExtensionInterface public function buildForm(FormBuilderInterface $builder, array $options): void; /** + * @phpstan-param FormInterface $form * @param array $options */ public function buildView(FormView $view, FormInterface $form, array $options): void; /** + * @phpstan-param FormInterface $form * @param array $options */ public function finishView(FormView $view, FormInterface $form, array $options): void; diff --git a/stubs/Symfony/Component/Form/FormTypeInterface.stub b/stubs/Symfony/Component/Form/FormTypeInterface.stub index cebbc1c2..85bb539c 100644 --- a/stubs/Symfony/Component/Form/FormTypeInterface.stub +++ b/stubs/Symfony/Component/Form/FormTypeInterface.stub @@ -2,6 +2,9 @@ namespace Symfony\Component\Form; +/** + * @template TData + */ interface FormTypeInterface { /** @@ -10,11 +13,13 @@ interface FormTypeInterface public function buildForm(FormBuilderInterface $builder, array $options): void; /** + * @phpstan-param FormInterface $form * @param array $options */ public function buildView(FormView $view, FormInterface $form, array $options): void; /** + * @phpstan-param FormInterface $form * @param array $options */ public function finishView(FormView $view, FormInterface $form, array $options): void; diff --git a/stubs/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.stub b/stubs/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.stub new file mode 100644 index 00000000..2856e32b --- /dev/null +++ b/stubs/Symfony/Component/OptionsResolver/Exception/InvalidOptionsException.stub @@ -0,0 +1,7 @@ +gatherAssertTypes(__DIR__ . '/data/FormInterface_getErrors.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/cache.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/form_data_type.php'); } /** diff --git a/tests/Type/Symfony/data/form_data_type.php b/tests/Type/Symfony/data/form_data_type.php new file mode 100644 index 00000000..524a5b7c --- /dev/null +++ b/tests/Type/Symfony/data/form_data_type.php @@ -0,0 +1,72 @@ + + */ +class DataClassType extends AbstractType +{ + + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add('foo', NumberType::class) + ->add('bar', TextType::class) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver + ->setDefaults([ + 'data_class' => DataClass::class, + ]) + ; + } + +} + +class FormFactoryAwareClass +{ + + /** @var FormFactoryInterface */ + private $formFactory; + + public function __construct(FormFactoryInterface $formFactory) + { + $this->formFactory = $formFactory; + } + + public function doSomething(): void + { + $form = $this->formFactory->create(DataClassType::class, new DataClass()); + assertType('GenericFormDataType\DataClass', $form->getData()); + } + + public function doSomethingNullable(): void + { + $form = $this->formFactory->create(DataClassType::class); + assertType('GenericFormDataType\DataClass|null', $form->getData()); + } + +} From 7e78605a699d183f5a6936cf91904f4c16ca79b2 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Fri, 14 Apr 2023 18:58:33 +0200 Subject: [PATCH 16/29] Fix AbstractType stub --- stubs/Symfony/Component/Form/AbstractType.stub | 18 ++++++++++++++++++ .../Component/Form/FormTypeInterface.stub | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/stubs/Symfony/Component/Form/AbstractType.stub b/stubs/Symfony/Component/Form/AbstractType.stub index 76170a02..da2b1439 100644 --- a/stubs/Symfony/Component/Form/AbstractType.stub +++ b/stubs/Symfony/Component/Form/AbstractType.stub @@ -9,4 +9,22 @@ namespace Symfony\Component\Form; */ abstract class AbstractType implements FormTypeInterface { + + /** + * @param array $options + */ + public function buildForm(FormBuilderInterface $builder, array $options): void; + + /** + * @param FormInterface $form + * @param array $options + */ + public function buildView(FormView $view, FormInterface $form, array $options): void; + + /** + * @param FormInterface $form + * @param array $options + */ + public function finishView(FormView $view, FormInterface $form, array $options): void; + } diff --git a/stubs/Symfony/Component/Form/FormTypeInterface.stub b/stubs/Symfony/Component/Form/FormTypeInterface.stub index 85bb539c..2f745283 100644 --- a/stubs/Symfony/Component/Form/FormTypeInterface.stub +++ b/stubs/Symfony/Component/Form/FormTypeInterface.stub @@ -13,13 +13,13 @@ interface FormTypeInterface public function buildForm(FormBuilderInterface $builder, array $options): void; /** - * @phpstan-param FormInterface $form + * @param FormInterface $form * @param array $options */ public function buildView(FormView $view, FormInterface $form, array $options): void; /** - * @phpstan-param FormInterface $form + * @param FormInterface $form * @param array $options */ public function finishView(FormView $view, FormInterface $form, array $options): void; From db75c81816167e797b8d74b545470d5244c8a7d4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 01:41:01 +0000 Subject: [PATCH 17/29] Update build-cs --- build-cs/composer.lock | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/build-cs/composer.lock b/build-cs/composer.lock index c25a151a..2eafc159 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -9,16 +9,16 @@ "packages-dev": [ { "name": "consistence-community/coding-standard", - "version": "3.11.2", + "version": "3.11.3", "source": { "type": "git", "url": "https://github.com/consistence-community/coding-standard.git", - "reference": "adb4be482e76990552bf624309d2acc8754ba1bd" + "reference": "f38e06327d5bf80ff5ff523a2c05e623b5e8d8b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/adb4be482e76990552bf624309d2acc8754ba1bd", - "reference": "adb4be482e76990552bf624309d2acc8754ba1bd", + "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/f38e06327d5bf80ff5ff523a2c05e623b5e8d8b1", + "reference": "f38e06327d5bf80ff5ff523a2c05e623b5e8d8b1", "shasum": "" }, "require": { @@ -70,9 +70,9 @@ ], "support": { "issues": "https://github.com/consistence-community/coding-standard/issues", - "source": "https://github.com/consistence-community/coding-standard/tree/3.11.2" + "source": "https://github.com/consistence-community/coding-standard/tree/3.11.3" }, - "time": "2022-06-21T08:36:36+00:00" + "time": "2023-03-27T14:55:41+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -154,16 +154,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.15.3", + "version": "1.18.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "61800f71a5526081d1b5633766aa88341f1ade76" + "reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/61800f71a5526081d1b5633766aa88341f1ade76", - "reference": "61800f71a5526081d1b5633766aa88341f1ade76", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/22dcdfd725ddf99583bfe398fc624ad6c5004a0f", + "reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f", "shasum": "" }, "require": { @@ -193,38 +193,38 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.15.3" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.18.1" }, - "time": "2022-12-20T20:56:55+00:00" + "time": "2023-04-07T11:51:11+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.8.0", + "version": "8.10.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "59e25146a4ef0a7b194c5bc55b32dd414345db89" + "reference": "c4e213e6e57f741451a08e68ef838802eec92287" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/59e25146a4ef0a7b194c5bc55b32dd414345db89", - "reference": "59e25146a4ef0a7b194c5bc55b32dd414345db89", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/c4e213e6e57f741451a08e68ef838802eec92287", + "reference": "c4e213e6e57f741451a08e68ef838802eec92287", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": ">=1.15.2 <1.16.0", + "phpstan/phpdoc-parser": ">=1.18.0 <1.19.0", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.9.6", - "phpstan/phpstan-deprecation-rules": "1.1.1", - "phpstan/phpstan-phpunit": "1.0.0|1.3.3", - "phpstan/phpstan-strict-rules": "1.4.4", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.27" + "phpstan/phpstan": "1.4.10|1.10.11", + "phpstan/phpstan-deprecation-rules": "1.1.3", + "phpstan/phpstan-phpunit": "1.0.0|1.3.11", + "phpstan/phpstan-strict-rules": "1.5.1", + "phpunit/phpunit": "7.5.20|8.5.21|9.6.6|10.0.19" }, "type": "phpcodesniffer-standard", "extra": { @@ -234,7 +234,7 @@ }, "autoload": { "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard" + "SlevomatCodingStandard\\": "SlevomatCodingStandard/" } }, "notification-url": "https://packagist.org/downloads/", @@ -248,7 +248,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.8.0" + "source": "https://github.com/slevomat/coding-standard/tree/8.10.0" }, "funding": [ { @@ -260,7 +260,7 @@ "type": "tidelift" } ], - "time": "2023-01-09T10:46:13+00:00" + "time": "2023-04-10T07:39:29+00:00" }, { "name": "squizlabs/php_codesniffer", From ddaa09397220a43bdfc9e6c0b30c6ece3e0d9a29 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 01:28:58 +0000 Subject: [PATCH 18/29] Update dependency slevomat/coding-standard to v8.11.0 --- build-cs/composer.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/build-cs/composer.lock b/build-cs/composer.lock index 2eafc159..0cea3f9e 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -154,16 +154,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.18.1", + "version": "1.20.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f" + "reference": "90490bd8fd8530a272043c4950c180b6d0cf5f81" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/22dcdfd725ddf99583bfe398fc624ad6c5004a0f", - "reference": "22dcdfd725ddf99583bfe398fc624ad6c5004a0f", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/90490bd8fd8530a272043c4950c180b6d0cf5f81", + "reference": "90490bd8fd8530a272043c4950c180b6d0cf5f81", "shasum": "" }, "require": { @@ -193,38 +193,38 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.18.1" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.2" }, - "time": "2023-04-07T11:51:11+00:00" + "time": "2023-04-22T12:59:35+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.10.0", + "version": "8.11.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "c4e213e6e57f741451a08e68ef838802eec92287" + "reference": "91428d5bcf7db93a842bcf97f465edf62527f3ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/c4e213e6e57f741451a08e68ef838802eec92287", - "reference": "c4e213e6e57f741451a08e68ef838802eec92287", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/91428d5bcf7db93a842bcf97f465edf62527f3ea", + "reference": "91428d5bcf7db93a842bcf97f465edf62527f3ea", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": ">=1.18.0 <1.19.0", + "phpstan/phpdoc-parser": ">=1.20.0 <1.21.0", "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.10.11", + "phpstan/phpstan": "1.10.14", "phpstan/phpstan-deprecation-rules": "1.1.3", - "phpstan/phpstan-phpunit": "1.0.0|1.3.11", + "phpstan/phpstan-phpunit": "1.3.11", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.6|10.0.19" + "phpunit/phpunit": "7.5.20|8.5.21|9.6.6|10.1.1" }, "type": "phpcodesniffer-standard", "extra": { @@ -248,7 +248,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.10.0" + "source": "https://github.com/slevomat/coding-standard/tree/8.11.0" }, "funding": [ { @@ -260,7 +260,7 @@ "type": "tidelift" } ], - "time": "2023-04-10T07:39:29+00:00" + "time": "2023-04-21T15:51:44+00:00" }, { "name": "squizlabs/php_codesniffer", From bc67cd94f6c39c07b3427fe06aa7c237d06a704e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 02:05:48 +0000 Subject: [PATCH 19/29] Update dependency slevomat/coding-standard to v8.11.1 --- build-cs/composer.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/build-cs/composer.lock b/build-cs/composer.lock index 0cea3f9e..c59ffc5f 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -154,16 +154,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.20.2", + "version": "1.20.3", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "90490bd8fd8530a272043c4950c180b6d0cf5f81" + "reference": "6c04009f6cae6eda2f040745b6b846080ef069c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/90490bd8fd8530a272043c4950c180b6d0cf5f81", - "reference": "90490bd8fd8530a272043c4950c180b6d0cf5f81", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6c04009f6cae6eda2f040745b6b846080ef069c2", + "reference": "6c04009f6cae6eda2f040745b6b846080ef069c2", "shasum": "" }, "require": { @@ -193,22 +193,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.3" }, - "time": "2023-04-22T12:59:35+00:00" + "time": "2023-04-25T09:01:03+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.11.0", + "version": "8.11.1", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "91428d5bcf7db93a842bcf97f465edf62527f3ea" + "reference": "af87461316b257e46e15bb041dca6fca3796d822" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/91428d5bcf7db93a842bcf97f465edf62527f3ea", - "reference": "91428d5bcf7db93a842bcf97f465edf62527f3ea", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/af87461316b257e46e15bb041dca6fca3796d822", + "reference": "af87461316b257e46e15bb041dca6fca3796d822", "shasum": "" }, "require": { @@ -248,7 +248,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.11.0" + "source": "https://github.com/slevomat/coding-standard/tree/8.11.1" }, "funding": [ { @@ -260,7 +260,7 @@ "type": "tidelift" } ], - "time": "2023-04-21T15:51:44+00:00" + "time": "2023-04-24T08:19:01+00:00" }, { "name": "squizlabs/php_codesniffer", From c8493938b6ea628d9e68ec231c36ad1b13587649 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 00:51:42 +0000 Subject: [PATCH 20/29] Update dependency slevomat/coding-standard to v8.12.0 --- build-cs/composer.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/build-cs/composer.lock b/build-cs/composer.lock index c59ffc5f..db122416 100644 --- a/build-cs/composer.lock +++ b/build-cs/composer.lock @@ -154,16 +154,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.20.3", + "version": "1.20.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6c04009f6cae6eda2f040745b6b846080ef069c2" + "reference": "7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6c04009f6cae6eda2f040745b6b846080ef069c2", - "reference": "6c04009f6cae6eda2f040745b6b846080ef069c2", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd", + "reference": "7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd", "shasum": "" }, "require": { @@ -193,22 +193,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.3" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.4" }, - "time": "2023-04-25T09:01:03+00:00" + "time": "2023-05-02T09:19:37+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.11.1", + "version": "8.12.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "af87461316b257e46e15bb041dca6fca3796d822" + "reference": "cc04334ed0ce5a251389112fbd2dbe1dbc931ae8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/af87461316b257e46e15bb041dca6fca3796d822", - "reference": "af87461316b257e46e15bb041dca6fca3796d822", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/cc04334ed0ce5a251389112fbd2dbe1dbc931ae8", + "reference": "cc04334ed0ce5a251389112fbd2dbe1dbc931ae8", "shasum": "" }, "require": { @@ -220,11 +220,11 @@ "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.14", + "phpstan/phpstan": "1.10.15", "phpstan/phpstan-deprecation-rules": "1.1.3", "phpstan/phpstan-phpunit": "1.3.11", "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.6|10.1.1" + "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.1.3" }, "type": "phpcodesniffer-standard", "extra": { @@ -248,7 +248,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.11.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.12.0" }, "funding": [ { @@ -260,7 +260,7 @@ "type": "tidelift" } ], - "time": "2023-04-24T08:19:01+00:00" + "time": "2023-05-14T20:06:01+00:00" }, { "name": "squizlabs/php_codesniffer", From 7332b90dfc291ac5b4b83fbca2081936faa1e3f9 Mon Sep 17 00:00:00 2001 From: Nico Haase Date: Fri, 12 May 2023 16:51:50 +0200 Subject: [PATCH 21/29] Extend Serializer stubs --- .../Component/Serializer/Encoder/DecoderInterface.stub | 3 ++- .../Component/Serializer/Encoder/EncoderInterface.stub | 3 ++- .../Serializer/Normalizer/DenormalizerInterface.stub | 3 ++- .../Component/Serializer/Normalizer/NormalizerInterface.stub | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub b/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub index a9923edf..e19f772e 100644 --- a/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub +++ b/stubs/Symfony/Component/Serializer/Encoder/DecoderInterface.stub @@ -18,7 +18,8 @@ interface DecoderInterface /** * @param string $format Format name + * @param array $context * @return bool */ - public function supportsDecoding($format); + public function supportsDecoding($format, array $context = []); } diff --git a/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub b/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub index 2d97bde3..11e374eb 100644 --- a/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub +++ b/stubs/Symfony/Component/Serializer/Encoder/EncoderInterface.stub @@ -18,7 +18,8 @@ interface EncoderInterface /** * @param string $format Format name + * @param array $context * @return bool */ - public function supportsEncoding($format); + public function supportsEncoding($format, array $context = []); } diff --git a/stubs/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.stub b/stubs/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.stub index cb9af06d..b7e9968b 100644 --- a/stubs/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.stub +++ b/stubs/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.stub @@ -33,7 +33,8 @@ interface DenormalizerInterface * @param mixed $data * @param string $type * @param string|null $format + * @param array $context * @return bool */ - public function supportsDenormalization($data, $type, $format = null); + public function supportsDenormalization($data, $type, $format = null, array $context = []); } diff --git a/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub b/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub index fac60042..ba86b6b6 100644 --- a/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub +++ b/stubs/Symfony/Component/Serializer/Normalizer/NormalizerInterface.stub @@ -27,7 +27,9 @@ interface NormalizerInterface /** * @param mixed $data * @param string|null $format + * @param array $context + * * @return bool */ - public function supportsNormalization($data, $format = null); + public function supportsNormalization($data, $format = null, array $context = []); } From 8f1dab28569c92d8d3f73d5d5947d3851655759e Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 25 May 2023 15:27:48 +0200 Subject: [PATCH 22/29] Next-gen coding standard workflow --- .gitattributes | 1 - .github/renovate.json | 5 - .github/workflows/build.yml | 14 +- .gitignore | 1 + Makefile | 10 +- build-cs/.gitignore | 1 - build-cs/composer.json | 13 -- build-cs/composer.lock | 331 ------------------------------------ phpcs.xml | 112 ------------ 9 files changed, 21 insertions(+), 467 deletions(-) delete mode 100644 build-cs/.gitignore delete mode 100644 build-cs/composer.json delete mode 100644 build-cs/composer.lock delete mode 100644 phpcs.xml diff --git a/.gitattributes b/.gitattributes index 184bf6ae..1545ee73 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,7 +7,6 @@ tmp export-ignore .gitignore export-ignore .travis.yml export-ignore Makefile export-ignore -phpcs.xml export-ignore phpstan.neon export-ignore phpstan-baseline.neon export-ignore phpunit.xml export-ignore diff --git a/.github/renovate.json b/.github/renovate.json index b775cc18..d3f5961e 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -10,11 +10,6 @@ "enabled": true, "groupName": "root-composer" }, - { - "matchPaths": ["build-cs/**"], - "enabled": true, - "groupName": "build-cs" - }, { "matchPaths": [".github/**"], "enabled": true, diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96765433..ba129bc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: - name: "Lint" run: "make lint" - coding-standards: + coding-standard: name: "Coding Standard" runs-on: "ubuntu-latest" @@ -51,11 +51,17 @@ jobs: - name: "Checkout" uses: actions/checkout@v3 + - name: "Checkout build-cs" + uses: actions/checkout@v3 + with: + repository: "phpstan/build-cs" + path: "build-cs" + - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: coverage: "none" - php-version: "8.0" + php-version: "8.2" - name: "Validate Composer" run: "composer validate" @@ -63,6 +69,10 @@ jobs: - name: "Install dependencies" run: "composer install --no-interaction --no-progress" + - name: "Install build-cs dependencies" + working-directory: "build-cs" + run: "composer install --no-interaction --no-progress" + - name: "Lint" run: "make lint" diff --git a/.gitignore b/.gitignore index 2db21315..7de9f3c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /tests/tmp +/build-cs /vendor /composer.lock .phpunit.result.cache diff --git a/Makefile b/Makefile index b34d0fec..ecd8cfb2 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,19 @@ lint: php vendor/bin/parallel-lint --colors \ src tests +.PHONY: cs-install +cs-install: + git clone https://github.com/phpstan/build-cs.git || true + git -C build-cs fetch origin && git -C build-cs reset --hard origin/main + composer install --working-dir build-cs + .PHONY: cs cs: - composer install --working-dir build-cs && php build-cs/vendor/bin/phpcs + php build-cs/vendor/bin/phpcs --standard=build-cs/phpcs.xml src tests .PHONY: cs-fix cs-fix: - php build-cs/vendor/bin/phpcbf + php build-cs/vendor/bin/phpcbf --standard=build-cs/phpcs.xml src tests .PHONY: phpstan phpstan: diff --git a/build-cs/.gitignore b/build-cs/.gitignore deleted file mode 100644 index 61ead866..00000000 --- a/build-cs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/vendor diff --git a/build-cs/composer.json b/build-cs/composer.json deleted file mode 100644 index 16a240bc..00000000 --- a/build-cs/composer.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "require-dev": { - "consistence-community/coding-standard": "^3.11.0", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0.0", - "slevomat/coding-standard": "^8.8.0", - "squizlabs/php_codesniffer": "^3.5.3" - }, - "config": { - "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true - } - } -} diff --git a/build-cs/composer.lock b/build-cs/composer.lock deleted file mode 100644 index db122416..00000000 --- a/build-cs/composer.lock +++ /dev/null @@ -1,331 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "e69c1916405a7e3c8001c1b609a0ee61", - "packages": [], - "packages-dev": [ - { - "name": "consistence-community/coding-standard", - "version": "3.11.3", - "source": { - "type": "git", - "url": "https://github.com/consistence-community/coding-standard.git", - "reference": "f38e06327d5bf80ff5ff523a2c05e623b5e8d8b1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/f38e06327d5bf80ff5ff523a2c05e623b5e8d8b1", - "reference": "f38e06327d5bf80ff5ff523a2c05e623b5e8d8b1", - "shasum": "" - }, - "require": { - "php": "~8.0", - "slevomat/coding-standard": "~8.0", - "squizlabs/php_codesniffer": "~3.7.0" - }, - "replace": { - "consistence/coding-standard": "3.10.*" - }, - "require-dev": { - "phing/phing": "2.17.0", - "php-parallel-lint/php-parallel-lint": "1.3.1", - "phpunit/phpunit": "9.5.10" - }, - "type": "library", - "autoload": { - "psr-4": { - "Consistence\\": [ - "Consistence" - ] - }, - "classmap": [ - "Consistence" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "VaĊĦek Purchart", - "email": "me@vasekpurchart.cz", - "homepage": "http://vasekpurchart.cz" - } - ], - "description": "Consistence - Coding Standard - PHP Code Sniffer rules", - "keywords": [ - "Coding Standard", - "PHPCodeSniffer", - "codesniffer", - "coding", - "cs", - "phpcs", - "ruleset", - "sniffer", - "standard" - ], - "support": { - "issues": "https://github.com/consistence-community/coding-standard/issues", - "source": "https://github.com/consistence-community/coding-standard/tree/3.11.3" - }, - "time": "2023-03-27T14:55:41+00:00" - }, - { - "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "4be43904336affa5c2f70744a348312336afd0da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", - "reference": "4be43904336affa5c2f70744a348312336afd0da", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.4", - "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" - }, - "require-dev": { - "composer/composer": "*", - "ext-json": "*", - "ext-zip": "*", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0", - "yoast/phpunit-polyfills": "^1.0" - }, - "type": "composer-plugin", - "extra": { - "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" - }, - "autoload": { - "psr-4": { - "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Franck Nijhof", - "email": "franck.nijhof@dealerdirect.com", - "homepage": "http://www.frenck.nl", - "role": "Developer / IT Manager" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" - } - ], - "description": "PHP_CodeSniffer Standards Composer Installer Plugin", - "homepage": "http://www.dealerdirect.com", - "keywords": [ - "PHPCodeSniffer", - "PHP_CodeSniffer", - "code quality", - "codesniffer", - "composer", - "installer", - "phpcbf", - "phpcs", - "plugin", - "qa", - "quality", - "standard", - "standards", - "style guide", - "stylecheck", - "tests" - ], - "support": { - "issues": "https://github.com/PHPCSStandards/composer-installer/issues", - "source": "https://github.com/PHPCSStandards/composer-installer" - }, - "time": "2023-01-05T11:28:13+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "1.20.4", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd", - "reference": "7d568c87a9df9c5f7e8b5f075fc469aa8cb0a4cd", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.5", - "phpstan/phpstan-phpunit": "^1.1", - "phpstan/phpstan-strict-rules": "^1.0", - "phpunit/phpunit": "^9.5", - "symfony/process": "^5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.20.4" - }, - "time": "2023-05-02T09:19:37+00:00" - }, - { - "name": "slevomat/coding-standard", - "version": "8.12.0", - "source": { - "type": "git", - "url": "https://github.com/slevomat/coding-standard.git", - "reference": "cc04334ed0ce5a251389112fbd2dbe1dbc931ae8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/cc04334ed0ce5a251389112fbd2dbe1dbc931ae8", - "reference": "cc04334ed0ce5a251389112fbd2dbe1dbc931ae8", - "shasum": "" - }, - "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", - "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": ">=1.20.0 <1.21.0", - "squizlabs/php_codesniffer": "^3.7.1" - }, - "require-dev": { - "phing/phing": "2.17.4", - "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.15", - "phpstan/phpstan-deprecation-rules": "1.1.3", - "phpstan/phpstan-phpunit": "1.3.11", - "phpstan/phpstan-strict-rules": "1.5.1", - "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.1.3" - }, - "type": "phpcodesniffer-standard", - "extra": { - "branch-alias": { - "dev-master": "8.x-dev" - } - }, - "autoload": { - "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", - "keywords": [ - "dev", - "phpcs" - ], - "support": { - "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.12.0" - }, - "funding": [ - { - "url": "https://github.com/kukulich", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", - "type": "tidelift" - } - ], - "time": "2023-05-14T20:06:01+00:00" - }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.7.2", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards", - "static analysis" - ], - "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" - }, - "time": "2023-02-22T23:07:41+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.3.0" -} diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 3412c956..00000000 --- a/phpcs.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - src - tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 - - - - - - 10 - - - - - - - - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - tests/*/data - tests/tmp - From c7ad6f67eb21ae2c50e14823c923911bed6957d0 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 8 Jun 2023 10:18:44 +0200 Subject: [PATCH 23/29] Require PHPStan 1.11 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 22501953..14ab0970 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "php": "^7.2 || ^8.0", "ext-simplexml": "*", - "phpstan/phpstan": "^1.9.18" + "phpstan/phpstan": "^1.11" }, "conflict": { "symfony/framework-bundle": "<3.0" From 30915c323c793b3440d5953de9b5ea5165d99a8e Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 8 Jun 2023 10:18:51 +0200 Subject: [PATCH 24/29] Modernize rules with RuleErrorBuilder --- .../ContainerInterfacePrivateServiceRule.php | 10 +++++----- .../ContainerInterfaceUnknownServiceRule.php | 9 ++++----- .../InvalidArgumentDefaultValueRule.php | 19 ++++++++++++------ .../Symfony/InvalidOptionDefaultValueRule.php | 20 +++++++++++++------ src/Rules/Symfony/UndefinedArgumentRule.php | 7 ++----- src/Rules/Symfony/UndefinedOptionRule.php | 7 ++----- 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php b/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php index 0a3a3d3e..5e10c2b8 100644 --- a/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php +++ b/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; +use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Symfony\ServiceMap; use PHPStan\TrinaryLogic; use PHPStan\Type\ObjectType; @@ -32,9 +32,6 @@ public function getNodeType(): string return MethodCall::class; } - /** - * @return (string|RuleError)[] errors - */ public function processNode(Node $node, Scope $scope): array { if (!$node->name instanceof Node\Identifier) { @@ -72,7 +69,10 @@ public function processNode(Node $node, Scope $scope): array if ($serviceId !== null) { $service = $this->serviceMap->getService($serviceId); if ($service !== null && !$service->isPublic()) { - return [sprintf('Service "%s" is private.', $serviceId)]; + return [ + RuleErrorBuilder::message(sprintf('Service "%s" is private.', $serviceId)) + ->build(), + ]; } } diff --git a/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php b/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php index 417f51f5..ccc1999e 100644 --- a/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php +++ b/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php @@ -7,7 +7,7 @@ use PhpParser\PrettyPrinter\Standard; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; +use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Symfony\ServiceMap; use PHPStan\Type\ObjectType; use PHPStan\Type\Symfony\Helper; @@ -36,9 +36,6 @@ public function getNodeType(): string return MethodCall::class; } - /** - * @return (string|RuleError)[] errors - */ public function processNode(Node $node, Scope $scope): array { if (!$node->name instanceof Node\Identifier) { @@ -73,7 +70,9 @@ public function processNode(Node $node, Scope $scope): array $service = $this->serviceMap->getService($serviceId); $serviceIdType = $scope->getType($node->getArgs()[0]->value); if ($service === null && !$scope->getType(Helper::createMarkerNode($node->var, $serviceIdType, $this->printer))->equals($serviceIdType)) { - return [sprintf('Service "%s" is not registered in the container.', $serviceId)]; + return [ + RuleErrorBuilder::message(sprintf('Service "%s" is not registered in the container.', $serviceId))->build(), + ]; } } diff --git a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php index e48f8718..a55881ce 100644 --- a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; +use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Type\ArrayType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\IntegerType; @@ -30,9 +30,6 @@ public function getNodeType(): string return MethodCall::class; } - /** - * @return (string|RuleError)[] errors - */ public function processNode(Node $node, Scope $scope): array { if (!(new ObjectType('Symfony\Component\Console\Command\Command'))->isSuperTypeOf($scope->getType($node->var))->yes()) { @@ -62,12 +59,22 @@ public function processNode(Node $node, Scope $scope): array // not an array if (($mode & 4) !== 4 && !(new UnionType([new StringType(), new NullType()]))->isSuperTypeOf($defaultType)->yes()) { - return [sprintf('Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects string|null, %s given.', $defaultType->describe(VerbosityLevel::typeOnly()))]; + return [ + RuleErrorBuilder::message(sprintf( + 'Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects string|null, %s given.', + $defaultType->describe(VerbosityLevel::typeOnly()) + ))->build(), + ]; } // is array if (($mode & 4) === 4 && !(new UnionType([new ArrayType(new IntegerType(), new StringType()), new NullType()]))->isSuperTypeOf($defaultType)->yes()) { - return [sprintf('Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects array|null, %s given.', $defaultType->describe(VerbosityLevel::typeOnly()))]; + return [ + RuleErrorBuilder::message(sprintf( + 'Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects array|null, %s given.', + $defaultType->describe(VerbosityLevel::typeOnly()) + ))->build(), + ]; } return []; diff --git a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php index 171f94f1..6964d25e 100644 --- a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\MethodCall; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; +use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Type\ArrayType; use PHPStan\Type\BooleanType; use PHPStan\Type\Constant\ConstantIntegerType; @@ -32,9 +32,6 @@ public function getNodeType(): string return MethodCall::class; } - /** - * @return (string|RuleError)[] errors - */ public function processNode(Node $node, Scope $scope): array { if (!(new ObjectType('Symfony\Component\Console\Command\Command'))->isSuperTypeOf($scope->getType($node->var))->yes()) { @@ -66,13 +63,24 @@ public function processNode(Node $node, Scope $scope): array if (($mode & 8) !== 8) { $checkType = new UnionType([new StringType(), new IntegerType(), new NullType(), new BooleanType()]); if (!$checkType->isSuperTypeOf($defaultType)->yes()) { - return [sprintf('Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects %s, %s given.', $checkType->describe(VerbosityLevel::typeOnly()), $defaultType->describe(VerbosityLevel::typeOnly()))]; + return [ + RuleErrorBuilder::message(sprintf( + 'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects %s, %s given.', + $checkType->describe(VerbosityLevel::typeOnly()), + $defaultType->describe(VerbosityLevel::typeOnly()) + ))->build(), + ]; } } // is array if (($mode & 8) === 8 && !(new UnionType([new ArrayType(new MixedType(), new StringType()), new NullType()]))->isSuperTypeOf($defaultType)->yes()) { - return [sprintf('Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects array|null, %s given.', $defaultType->describe(VerbosityLevel::typeOnly()))]; + return [ + RuleErrorBuilder::message(sprintf( + 'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects array|null, %s given.', + $defaultType->describe(VerbosityLevel::typeOnly()) + ))->build(), + ]; } return []; diff --git a/src/Rules/Symfony/UndefinedArgumentRule.php b/src/Rules/Symfony/UndefinedArgumentRule.php index 52f90241..07f35e2a 100644 --- a/src/Rules/Symfony/UndefinedArgumentRule.php +++ b/src/Rules/Symfony/UndefinedArgumentRule.php @@ -8,7 +8,7 @@ use PhpParser\PrettyPrinter\Standard; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; +use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\ObjectType; use PHPStan\Type\Symfony\Helper; @@ -39,9 +39,6 @@ public function getNodeType(): string return MethodCall::class; } - /** - * @return (string|RuleError)[] errors - */ public function processNode(Node $node, Scope $scope): array { $classReflection = $scope->getClassReflection(); @@ -78,7 +75,7 @@ public function processNode(Node $node, Scope $scope): array if ($scope->getType(Helper::createMarkerNode($node->var, $argType, $this->printer))->equals($argType)) { continue; } - $errors[] = sprintf('Command "%s" does not define argument "%s".', $name, $argName); + $errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define argument "%s".', $name, $argName))->build(); } } diff --git a/src/Rules/Symfony/UndefinedOptionRule.php b/src/Rules/Symfony/UndefinedOptionRule.php index 00dd750e..5a8dc8e3 100644 --- a/src/Rules/Symfony/UndefinedOptionRule.php +++ b/src/Rules/Symfony/UndefinedOptionRule.php @@ -8,7 +8,7 @@ use PhpParser\PrettyPrinter\Standard; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; +use PHPStan\Rules\RuleErrorBuilder; use PHPStan\Symfony\ConsoleApplicationResolver; use PHPStan\Type\ObjectType; use PHPStan\Type\Symfony\Helper; @@ -39,9 +39,6 @@ public function getNodeType(): string return MethodCall::class; } - /** - * @return (string|RuleError)[] errors - */ public function processNode(Node $node, Scope $scope): array { $classReflection = $scope->getClassReflection(); @@ -78,7 +75,7 @@ public function processNode(Node $node, Scope $scope): array if ($scope->getType(Helper::createMarkerNode($node->var, $optType, $this->printer))->equals($optType)) { continue; } - $errors[] = sprintf('Command "%s" does not define option "%s".', $name, $optName); + $errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define option "%s".', $name, $optName))->build(); } } From fdfd3f4f7b1f9a95f6d29d9715950d8140773785 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 8 Jun 2023 11:07:26 +0200 Subject: [PATCH 25/29] Error identifiers --- src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php | 1 + src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php | 4 +++- src/Rules/Symfony/InvalidArgumentDefaultValueRule.php | 4 ++-- src/Rules/Symfony/InvalidOptionDefaultValueRule.php | 4 ++-- src/Rules/Symfony/UndefinedArgumentRule.php | 4 +++- src/Rules/Symfony/UndefinedOptionRule.php | 4 +++- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php b/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php index 5e10c2b8..996d3b77 100644 --- a/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php +++ b/src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php @@ -71,6 +71,7 @@ public function processNode(Node $node, Scope $scope): array if ($service !== null && !$service->isPublic()) { return [ RuleErrorBuilder::message(sprintf('Service "%s" is private.', $serviceId)) + ->identifier('symfonyContainer.privateService') ->build(), ]; } diff --git a/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php b/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php index ccc1999e..fc7d9585 100644 --- a/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php +++ b/src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php @@ -71,7 +71,9 @@ public function processNode(Node $node, Scope $scope): array $serviceIdType = $scope->getType($node->getArgs()[0]->value); if ($service === null && !$scope->getType(Helper::createMarkerNode($node->var, $serviceIdType, $this->printer))->equals($serviceIdType)) { return [ - RuleErrorBuilder::message(sprintf('Service "%s" is not registered in the container.', $serviceId))->build(), + RuleErrorBuilder::message(sprintf('Service "%s" is not registered in the container.', $serviceId)) + ->identifier('symfonyContainer.serviceNotFound') + ->build(), ]; } } diff --git a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php index a55881ce..153d4af5 100644 --- a/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidArgumentDefaultValueRule.php @@ -63,7 +63,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects string|null, %s given.', $defaultType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('argument.type')->build(), ]; } @@ -73,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects array|null, %s given.', $defaultType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('argument.type')->build(), ]; } diff --git a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php index 6964d25e..1595f4a8 100644 --- a/src/Rules/Symfony/InvalidOptionDefaultValueRule.php +++ b/src/Rules/Symfony/InvalidOptionDefaultValueRule.php @@ -68,7 +68,7 @@ public function processNode(Node $node, Scope $scope): array 'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects %s, %s given.', $checkType->describe(VerbosityLevel::typeOnly()), $defaultType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('argument.type')->build(), ]; } } @@ -79,7 +79,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects array|null, %s given.', $defaultType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('argument.type')->build(), ]; } diff --git a/src/Rules/Symfony/UndefinedArgumentRule.php b/src/Rules/Symfony/UndefinedArgumentRule.php index 07f35e2a..cd8be894 100644 --- a/src/Rules/Symfony/UndefinedArgumentRule.php +++ b/src/Rules/Symfony/UndefinedArgumentRule.php @@ -75,7 +75,9 @@ public function processNode(Node $node, Scope $scope): array if ($scope->getType(Helper::createMarkerNode($node->var, $argType, $this->printer))->equals($argType)) { continue; } - $errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define argument "%s".', $name, $argName))->build(); + $errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define argument "%s".', $name, $argName)) + ->identifier('symfonyConsole.argumentNotFound') + ->build(); } } diff --git a/src/Rules/Symfony/UndefinedOptionRule.php b/src/Rules/Symfony/UndefinedOptionRule.php index 5a8dc8e3..095bd44d 100644 --- a/src/Rules/Symfony/UndefinedOptionRule.php +++ b/src/Rules/Symfony/UndefinedOptionRule.php @@ -75,7 +75,9 @@ public function processNode(Node $node, Scope $scope): array if ($scope->getType(Helper::createMarkerNode($node->var, $optType, $this->printer))->equals($optType)) { continue; } - $errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define option "%s".', $name, $optName))->build(); + $errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define option "%s".', $name, $optName)) + ->identifier('symfonyConsole.optionNotFound') + ->build(); } } From 34c64a368411bbffae2b291c90819cdeeb5f39a5 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 8 Jun 2023 11:12:16 +0200 Subject: [PATCH 26/29] Bump PHPStan dependencies --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 14ab0970..fc3e9368 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,8 @@ "require-dev": { "nikic/php-parser": "^4.13.0", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan-phpunit": "^1.0", - "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.3.11", + "phpstan/phpstan-strict-rules": "^1.5.1", "phpunit/phpunit": "^8.5.29 || ^9.5", "psr/container": "1.0 || 1.1.1", "symfony/config": "^5.4 || ^6.1", From 4f984e5ad88ba61632ad73d8388f2fe80419fd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Verlhac?= Date: Wed, 7 Jun 2023 12:47:04 +0200 Subject: [PATCH 27/29] feat: Sync Validor stubs with SF6.1 --- .../Component/Validator/ConstraintViolationInterface.stub | 3 +++ .../Validator/ConstraintViolationListInterface.stub | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/stubs/Symfony/Component/Validator/ConstraintViolationInterface.stub b/stubs/Symfony/Component/Validator/ConstraintViolationInterface.stub index ef3312bb..e7f2b8a2 100644 --- a/stubs/Symfony/Component/Validator/ConstraintViolationInterface.stub +++ b/stubs/Symfony/Component/Validator/ConstraintViolationInterface.stub @@ -2,6 +2,9 @@ namespace Symfony\Component\Validator; +/** + * @method string __toString() Converts the violation into a string for debugging purposes. Not implementing it is deprecated since Symfony 6.1. + */ interface ConstraintViolationInterface { } diff --git a/stubs/Symfony/Component/Validator/ConstraintViolationListInterface.stub b/stubs/Symfony/Component/Validator/ConstraintViolationListInterface.stub index 423bdfb0..00a2a9d5 100644 --- a/stubs/Symfony/Component/Validator/ConstraintViolationListInterface.stub +++ b/stubs/Symfony/Component/Validator/ConstraintViolationListInterface.stub @@ -3,8 +3,11 @@ namespace Symfony\Component\Validator; /** + * @extends \ArrayAccess * @extends \Traversable + * + * @method string __toString() Converts the violation into a string for debugging purposes. Not implementing it is deprecated since Symfony 6.1. */ -interface ConstraintViolationListInterface extends \Traversable +interface ConstraintViolationListInterface extends \Traversable, \Countable, \ArrayAccess { } From 771669a8ae0319a8842e0569bef1836c600de1b6 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 28 Aug 2023 17:31:11 +0200 Subject: [PATCH 28/29] Add a more precise return type for ParameterBag::keys in stubs --- stubs/Symfony/Component/HttpFoundation/ParameterBag.stub | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/stubs/Symfony/Component/HttpFoundation/ParameterBag.stub b/stubs/Symfony/Component/HttpFoundation/ParameterBag.stub index 00a40741..0a6858e3 100644 --- a/stubs/Symfony/Component/HttpFoundation/ParameterBag.stub +++ b/stubs/Symfony/Component/HttpFoundation/ParameterBag.stub @@ -7,5 +7,10 @@ namespace Symfony\Component\HttpFoundation; */ class ParameterBag implements \IteratorAggregate { - + /** + * @return list + */ + public function keys(): array + { + } } From 931c6b5bb46a17a35f8c799fd2515b08afa73154 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 00:15:15 +0000 Subject: [PATCH 29/29] chore(deps): update actions/checkout action to v4 --- .github/workflows/build.yml | 10 +++++----- .github/workflows/create-tag.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba129bc9..06457c85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Install PHP" uses: "shivammathur/setup-php@v2" @@ -49,10 +49,10 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Checkout build-cs" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: "phpstan/build-cs" path: "build-cs" @@ -99,7 +99,7 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Install PHP" uses: "shivammathur/setup-php@v2" @@ -138,7 +138,7 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Install PHP" uses: "shivammathur/setup-php@v2" diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 8452d986..a8535014 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -21,7 +21,7 @@ jobs: runs-on: "ubuntu-latest" steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.PHPSTAN_BOT_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92b72547..e4a8ac62 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: steps: - name: "Checkout" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Generate changelog id: changelog