diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/return_self_different_namespace.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/return_self_different_namespace.php new file mode 100644 index 00000000000..a6d3e9ce0b8 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/return_self_different_namespace.php @@ -0,0 +1,18 @@ + diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/twice_same_type.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/twice_same_type.php new file mode 100644 index 00000000000..677194110ec --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictTypedCallRector/Fixture/twice_same_type.php @@ -0,0 +1,22 @@ +getNumber(100); + } + + return $this->getNumber(10); + } + + private function getNumber(int $value): int + { + return $value; + } +} + +?> diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_array_possible_string.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_array_possible_string.php.inc new file mode 100644 index 00000000000..28e7fbe6f37 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector/Fixture/skip_array_possible_string.php.inc @@ -0,0 +1,17 @@ +parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) { return null; } @@ -136,6 +135,10 @@ private function isParamAccessedArrayDimFetch(Param $param, ClassMethod|Function return null; } + if (! $node->dim instanceof Expr) { + return null; + } + if (! $node->var instanceof Variable) { return null; } @@ -150,6 +153,12 @@ private function isParamAccessedArrayDimFetch(Param $param, ClassMethod|Function return null; } + // skip integer in possibly string type as string can be accessed via int + $dimType = $this->getType($node->dim); + if ($dimType->isInteger()->yes() && $variableType->isString()->maybe()) { + return null; + } + $isParamAccessedArrayDimFetch = true; return null; });