From 0d714fc24e0c4a72e0db9e5cb449a03b640ead2f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 16 Oct 2026 21:06:21 +0200 Subject: [PATCH] Declare array shapes on positional tuple returns --- .../NodeFactory/AssertArrayHasKeyCallFactory.php | 2 +- .../MethodCall/AssertComparisonToSpecificMethodRector.php | 7 ++++++- .../MethodCall/AssertIssetToSpecificMethodRector.php | 7 ++++++- .../Rector/StmtsAwareInterface/WithConsecutiveRector.php | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/rules/CodeQuality/NodeFactory/AssertArrayHasKeyCallFactory.php b/rules/CodeQuality/NodeFactory/AssertArrayHasKeyCallFactory.php index 9c910280..710d3543 100644 --- a/rules/CodeQuality/NodeFactory/AssertArrayHasKeyCallFactory.php +++ b/rules/CodeQuality/NodeFactory/AssertArrayHasKeyCallFactory.php @@ -44,7 +44,7 @@ private function isInsideTestCase(Scope $scope): bool } /** - * @return Arg[] + * @return array{Arg, Arg, Arg} */ private function createArgs(Variable $dimFetchVariable, Expr $dimExpr): array { diff --git a/rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php b/rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php index b7f14389..8d4ee12c 100644 --- a/rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php +++ b/rules/CodeQuality/Rector/MethodCall/AssertComparisonToSpecificMethodRector.php @@ -102,7 +102,12 @@ public function refactor(Node $node): ?Node return $this->processCallWithBinaryOp($node, $firstArgumentValue); } - private function processCallWithBinaryOp(MethodCall|StaticCall $node, BinaryOp $binaryOp): ?Node + /** + * @template TNode of MethodCall|StaticCall + * @param TNode $node + * @return TNode|null + */ + private function processCallWithBinaryOp(MethodCall|StaticCall $node, BinaryOp $binaryOp): MethodCall|StaticCall|null { $binaryOpClass = $binaryOp::class; diff --git a/rules/CodeQuality/Rector/MethodCall/AssertIssetToSpecificMethodRector.php b/rules/CodeQuality/Rector/MethodCall/AssertIssetToSpecificMethodRector.php index 8f91b599..9a11a6df 100644 --- a/rules/CodeQuality/Rector/MethodCall/AssertIssetToSpecificMethodRector.php +++ b/rules/CodeQuality/Rector/MethodCall/AssertIssetToSpecificMethodRector.php @@ -109,7 +109,12 @@ public function refactor(Node $node): ?Node return $this->refactorArrayDimFetchNode($node, $issetExpr); } - private function refactorArrayDimFetchNode(MethodCall|StaticCall $node, ArrayDimFetch $arrayDimFetch): Node + /** + * @template TNode of MethodCall|StaticCall + * @param TNode $node + * @return TNode + */ + private function refactorArrayDimFetchNode(MethodCall|StaticCall $node, ArrayDimFetch $arrayDimFetch): MethodCall|StaticCall { $this->identifierManipulator->renameNodeWithMap($node, [ AssertMethod::ASSERT_TRUE => 'assertArrayHasKey', diff --git a/rules/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector.php b/rules/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector.php index 1c10047c..29afa3b9 100644 --- a/rules/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector.php +++ b/rules/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector.php @@ -228,7 +228,7 @@ public function refactor(Node $node): null|array|Expression } /** - * @return Stmt[] + * @return array{Expression, Expression} */ private function refactorToWillReturnCallback( MethodCall $withConsecutiveMethodCall,