mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-22 10:43:35 +01:00
* make use of new simple-php-doc-parser * add ParamPhpDocNodeVisitor * remove uneeded contracts * skip bool instanceof * [ci-review] Rector Rectify * [ci-review] Rector Rectify Co-authored-by: kaizen-ci <info@kaizen-ci.org>
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\BetterPhpDocParser\PhpDocManipulator;
|
|
|
|
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
|
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
|
use Rector\Naming\Contract\RenameValueObjectInterface;
|
|
use Rector\Naming\ValueObject\ParamRename;
|
|
|
|
final class PropertyDocBlockManipulator
|
|
{
|
|
/**
|
|
* @var PhpDocInfoFactory
|
|
*/
|
|
private $phpDocInfoFactory;
|
|
|
|
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
|
{
|
|
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
|
}
|
|
|
|
/**
|
|
* @param ParamRename $renameValueObject
|
|
*/
|
|
public function renameParameterNameInDocBlock(RenameValueObjectInterface $renameValueObject): void
|
|
{
|
|
$functionLike = $renameValueObject->getFunctionLike();
|
|
|
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
|
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName());
|
|
if (! $paramTagValueNode instanceof ParamTagValueNode) {
|
|
return;
|
|
}
|
|
|
|
$paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName();
|
|
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
|
}
|
|
}
|