mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
503a6059f8
a8922f7431
skip temporarily match + throws downagrade in symfony/console, very unlikely to run
33 lines
1.2 KiB
PHP
33 lines
1.2 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\ValueObject\ParamRename;
|
|
final class PropertyDocBlockManipulator
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
|
*/
|
|
private $phpDocInfoFactory;
|
|
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
|
{
|
|
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
|
}
|
|
public function renameParameterNameInDocBlock(ParamRename $paramRename) : void
|
|
{
|
|
$functionLike = $paramRename->getFunctionLike();
|
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
|
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramRename->getCurrentName());
|
|
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
|
return;
|
|
}
|
|
$paramTagValueNode->parameterName = '$' . $paramRename->getExpectedName();
|
|
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
|
}
|
|
}
|