Skip to content

0.18.3 release note should include a way to re-print docblock after update #8201

@samsonasik

Description

@samsonasik

The release note should include a way to update docblock:

    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;

/cc @shyim

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions