diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_first.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_first.php.inc new file mode 100644 index 00000000000..ad4ca4d3f4b --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_first.php.inc @@ -0,0 +1,22 @@ +getString(); + } + + private function getString() + { + return '...'; + } +} diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_second.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_second.php.inc new file mode 100644 index 00000000000..8e0ffea2fe7 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/skip_once_type_and_native_call_second.php.inc @@ -0,0 +1,22 @@ +getString(); + } + + return array_map(function ($i) { + return $i; + }, []); + } + + private function getString() + { + return '...'; + } +} diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php index f3a2c13c4c7..ebf14bd479e 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector.php @@ -218,7 +218,7 @@ private function findCurrentScopeReturns(ClassMethod|Function_|Closure $node): a $this->traverseNodesWithCallable($node->stmts, static function (Node $node) use (&$currentScopeReturns): ?int { // skip scope nesting if ($node instanceof FunctionLike) { - return NodeTraverser::STOP_TRAVERSAL; + return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; } if (! $node instanceof Return_) {