BetterReflection\Reflection\ReflectionClass::getDocComment PHP Method

getDocComment() public method

public getDocComment ( ) : string
return string
    public function getDocComment()
    {
        if (!$this->node->hasAttribute('comments')) {
            return '';
        }
        /* @var \PhpParser\Comment\Doc $comment */
        $comment = $this->node->getAttribute('comments')[0];
        return $comment->getReformattedText();
    }

Usage Example

    function it_might_have_annotations(ReflectionClass $reflectionClass, AnnotationScanner $annotations)
    {
        $docBlock = <<<'BLOCK'
/**
 * @Target("CLASS")
 */
BLOCK;
        $expectedAnnotations = [new Target(['value' => "CLASS"])];
        $reflectionClass->getDocComment()->willReturn($docBlock);
        $annotations->scanForAnnotations($docBlock, $this->fileName, $this->imports)->willReturn(new Annotations($expectedAnnotations));
        $this->annotations()->shouldBeLike(new Annotations($expectedAnnotations));
    }
All Usage Examples Of BetterReflection\Reflection\ReflectionClass::getDocComment