public function __construct(
// here need to be injected ...
private readonly \Rector\Comments\NodeDocBlock\DocBlockUpdater $docBlockUpdater,
) {
}
public function refactor(Node $node)
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$routeDoctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Symfony\Component\Routing\Annotation\Route');
if (! $routeDoctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
return null;
}
$defaultsArrayItem = $routeDoctrineAnnotationTagValueNode->getValue('defaults');
if (! $defaultsArrayItem instanceof ArrayItemNode) {
$routeDoctrineAnnotationTagValueNode->values[] = new ArrayItemNode(
new CurlyListNode(),
'defaults',
);
// here need to be added.
$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);
return $node;
}
return null;
The release note should include a way to update docblock:
/cc @shyim