From 9ae89c067408367d4c8c276d537f6c368cd08051 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 21 Feb 2024 19:55:12 +0000 Subject: [PATCH] Updated Rector to commit 6095e3216f057fbf8dded18cf982bfab034f8086 https://github.com/rectorphp/rector-src/commit/6095e3216f057fbf8dded18cf982bfab034f8086 [TypeDeclaration] Allow abs() to return int when pass int arg on ReturnTypeFromStrictTypedCallRector (#5653) --- .../TypeAnalyzer/ReturnStrictTypeAnalyzer.php | 9 +++++++-- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php b/rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php index 75efdaff9f2..a22bd87b0d6 100644 --- a/rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php +++ b/rules/TypeDeclaration/TypeAnalyzer/ReturnStrictTypeAnalyzer.php @@ -3,7 +3,6 @@ declare (strict_types=1); namespace Rector\TypeDeclaration\TypeAnalyzer; -use PHPStan\Reflection\ParametersAcceptorSelector; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Expr\Array_; @@ -26,6 +25,8 @@ use PHPStan\Type\MixedType; use PHPStan\Type\StaticType; use PHPStan\Type\Type; use PHPStan\Type\TypeTraverser; +use Rector\NodeTypeResolver\Node\AttributeKey; +use Rector\NodeTypeResolver\PHPStan\ParametersAcceptorSelectorVariantsWrapper; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\Reflection\ReflectionResolver; use Rector\StaticTypeMapper\StaticTypeMapper; @@ -99,7 +100,11 @@ final class ReturnStrictTypeAnalyzer if ($methodReflection === null) { return null; } - $parametersAcceptorWithPhpDocs = ParametersAcceptorSelector::combineAcceptors($methodReflection->getVariants()); + $scope = $call->getAttribute(AttributeKey::SCOPE); + if (!$scope instanceof Scope) { + return null; + } + $parametersAcceptorWithPhpDocs = ParametersAcceptorSelectorVariantsWrapper::select($methodReflection, $call, $scope); if ($parametersAcceptorWithPhpDocs instanceof FunctionVariantWithPhpDocs) { // native return type is needed, as docblock can be false $returnType = $parametersAcceptorWithPhpDocs->getNativeReturnType(); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 7d7404f6433..6509bd6d595 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '99a79f8df18f4202f7c939b7996b9714abb78fe4'; + public const PACKAGE_VERSION = '6095e3216f057fbf8dded18cf982bfab034f8086'; /** * @api * @var string */ - public const RELEASE_DATE = '2024-02-21 23:16:34'; + public const RELEASE_DATE = '2024-02-22 02:52:54'; /** * @var int */