Updated Rector to commit 8f59d4e23ed974bf9eba52a075ef4d1e2604c80d

8f59d4e23e [Php80] Skip remove non-mixed type doc on MixedTypeRector (#5874)
This commit is contained in:
Tomas Votruba 2024-05-14 08:30:55 +00:00
parent faba2d1971
commit 4bcc8bbea0
3 changed files with 14 additions and 5 deletions

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\DeadCode\PhpDoc\TagRemover;
use PHPStan\Type\Type;
use PhpParser\Node\FunctionLike;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
@ -28,11 +29,11 @@ final class ParamTagRemover
$this->deadParamTagValueNodeAnalyzer = $deadParamTagValueNodeAnalyzer;
$this->docBlockUpdater = $docBlockUpdater;
}
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike) : bool
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike, ?Type $type = null) : bool
{
$hasChanged = \false;
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged) : ?int {
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged, $type, $phpDocInfo) : ?int {
if (!$docNode instanceof PhpDocTagNode) {
return null;
}
@ -43,6 +44,14 @@ final class ParamTagRemover
if ($docNode->name !== '@param') {
return null;
}
$paramType = $phpDocInfo->getParamType($docNode->value->parameterName);
if ($type instanceof Type) {
if ($type->equals($paramType)) {
$hasChanged = \true;
return PhpDocNodeTraverser::NODE_REMOVE;
}
return null;
}
if (!$this->deadParamTagValueNodeAnalyzer->isDead($docNode->value, $functionLike)) {
return null;
}

View File

@ -100,7 +100,7 @@ CODE_SAMPLE
$this->hasChanged = \false;
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$this->refactorParamTypes($node, $phpDocInfo);
$hasChanged = $this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node);
$hasChanged = $this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node, new MixedType());
if ($this->hasChanged) {
return $node;
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '035e7bdb76a5496c65b1c112933e4afe06ddc6f8';
public const PACKAGE_VERSION = '8f59d4e23ed974bf9eba52a075ef4d1e2604c80d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-05-13 19:19:41';
public const RELEASE_DATE = '2024-05-14 15:26:48';
/**
* @var int
*/