From 58923caaf6699bdffd0d03e831b4356e27121486 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 6 Dec 2023 13:28:15 +0000 Subject: [PATCH] Updated Rector to commit 043d43cd0347b4c2a73e896674a1f22ab1ce6d62 https://github.com/rectorphp/rector-src/commit/043d43cd0347b4c2a73e896674a1f22ab1ce6d62 [DeadCode] Remove unused @return mixed on RemoveUselessReturnTagRector (#5332) --- .../PhpDoc/DeadReturnTagValueNodeAnalyzer.php | 11 +++++++---- src/Application/VersionResolver.php | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php index 59c7418b70c..b3044e6c6f5 100644 --- a/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php +++ b/rules/DeadCode/PhpDoc/DeadReturnTagValueNodeAnalyzer.php @@ -78,9 +78,6 @@ final class DeadReturnTagValueNodeAnalyzer if ($scope instanceof Scope && $scope->isInTrait() && $returnTagValueNode->type instanceof ThisTypeNode) { return \false; } - if (!$this->hasUsefullPhpdocType($returnTagValueNode, $returnType)) { - return \true; - } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($returnType, $returnTagValueNode->type, $functionLike)) { return $this->isDeadNotEqual($returnTagValueNode, $returnType, $functionLike); } @@ -114,6 +111,9 @@ final class DeadReturnTagValueNodeAnalyzer if ($returnTagValueNode->type instanceof IdentifierTypeNode && (string) $returnTagValueNode->type === 'void') { return \true; } + if (!$this->hasUsefullPhpdocType($returnTagValueNode, $node)) { + return \true; + } $nodeType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node); $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($returnTagValueNode->type, $functionLike); return $docType instanceof UnionType && $this->typeComparator->areTypesEqual(TypeCombinator::removeNull($docType), $nodeType); @@ -133,11 +133,14 @@ final class DeadReturnTagValueNodeAnalyzer return \false; } /** - * in case of void,never there is no added value in "@return tag" + * exact different between @return and node return type * @param mixed $returnType */ private function hasUsefullPhpdocType(ReturnTagValueNode $returnTagValueNode, $returnType) : bool { + if ($returnTagValueNode->type instanceof IdentifierTypeNode && $returnTagValueNode->type->name === 'mixed') { + return \false; + } if (!$this->isVoidReturnType($returnType)) { return !$this->isNeverReturnType($returnType); } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 52e2207bd1c..86d78508a6a 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 = '1daab3c53f4a09669d2d915f7e245e984ace908d'; + public const PACKAGE_VERSION = '043d43cd0347b4c2a73e896674a1f22ab1ce6d62'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-06 17:46:31'; + public const RELEASE_DATE = '2023-12-06 14:26:04'; /** * @var int */