private function modifyDocBlock(ClassMethod $node) { $docComment = $node->getDocComment() ?: new Doc('/** ' . $node->name . ' */'); $docBlock = $this->docBlock->removeParamTags($docComment->getText()); $docBlock = $this->docBlock->addParams($node, $docBlock); $docComment->setText($docBlock); $this->reapplyModifiedNode($node, $docComment); }
public function it_modifies_class_method_nodes(ClassMethod $node, NodeFilter $filter, Doc $doc, Generator $generator, Param $param) { $filter->matchesFilterPattern($node)->willReturn(true); $filter->hasTypedParameters($node)->willReturn(true); $node->getDocComment()->willReturn($doc); $node->getAttributes()->willReturn(['comments' => []]); $node->setAttribute('comments', [$doc])->shouldBeCalled(); $node->getParams()->willReturn([$param]); $param->type = new Node\Name([]); $doc->getText()->shouldBeCalled(); $doc->setText(Argument::any())->shouldBeCalled(); $generator->removeParamTags('/** */')->willReturn('/** foo */'); $generator->addParams($node, '/** foo */')->willReturn('/** */'); $reflection = new \ReflectionProperty(ToDocBlockVisitor::class, 'docBlock'); $reflection->setAccessible(true); $reflection->setValue($this->getWrappedObject(), $generator); $this->leaveNode($node); if (null !== $param->type) { throw new FailedPredictionException('param type wasnt set to null'); } }