Parses the given doc comment and saves the result (description and
tags) in the parser's object. They can be retrieved by the
getTags() getTagValues() and getDescription() methods.
public parseDocComment ( string $docComment ) : void | ||
$docComment | string | A doc comment as returned by the reflection getDocComment() method |
Результат | void |
/** * Returns the description of a migration. * * If available it is fetched from the getDescription() method, if that returns an empty value * the class docblock is used instead. * * @param Version $version * @param DocCommentParser $parser * @return string */ protected function getMigrationDescription(Version $version, DocCommentParser $parser) { if ($version->getMigration()->getDescription()) { return $version->getMigration()->getDescription(); } else { $reflectedClass = new \ReflectionClass($version->getMigration()); $parser->parseDocComment($reflectedClass->getDocComment()); return str_replace([chr(10), chr(13)], ' ', $parser->getDescription()); } }
/** * @test */ public function eolCharacterCanBeNewlineOrCarriageReturn() { $parser = new DocCommentParser(); $parser->parseDocComment('/**' . chr(10) . ' * @var $foo integer' . chr(13) . chr(10) . ' * @var $bar string' . chr(10) . ' */'); $this->assertEquals(['$foo integer', '$bar string'], $parser->getTagValues('var')); }