mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 043d43cd0347b4c2a73e896674a1f22ab1ce6d62
043d43cd03
[DeadCode] Remove unused @return mixed on RemoveUselessReturnTagRector (#5332)
This commit is contained in:
parent
942be869a9
commit
58923caaf6
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue