03-reconstituting-a-docblock.php 744 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. require_once(__DIR__ . '/../vendor/autoload.php');
  3. use phpDocumentor\Reflection\DocBlock\Serializer;
  4. use phpDocumentor\Reflection\DocBlockFactory;
  5. $docComment = <<<DOCCOMMENT
  6. /**
  7. * This is an example of a summary.
  8. *
  9. * And here is an example of the description
  10. * of a DocBlock that can span multiple lines.
  11. *
  12. * @see \phpDocumentor\Reflection\DocBlock\StandardTagFactory
  13. */
  14. DOCCOMMENT;
  15. $factory = DocBlockFactory::createInstance();
  16. $docblock = $factory->create($docComment);
  17. // Create the serializer that will reconstitute the DocBlock back to its original form.
  18. $serializer = new Serializer();
  19. // Reconstitution is performed by the `getDocComment()` method.
  20. $reconstitutedDocComment = $serializer->getDocComment($docblock);