File: 01-interpreting-a-simple-docblock.php

package info (click to toggle)
php-phpdocumentor-reflection-docblock 6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,380 kB
  • sloc: php: 7,895; xml: 113; makefile: 57
file content (32 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

if (stream_resolve_include_path(__DIR__ . '/../../src/DocBlock/autoload.php')) {
    include_once __DIR__ . '/../../src/DocBlock/autoload.php';
} elseif (stream_resolve_include_path(__DIR__ . '/../../../phpDocumentor/Reflection/DocBlock/autoload.php')) {
    include_once('/../../../phpDocumentor/Reflection/DocBlock/autoload.php');
}

use phpDocumentor\Reflection\DocBlockFactory;

$docComment = <<<DOCCOMMENT
/**
 * This is an example of a summary.
 *
 * This is a Description. A Summary and Description are separated by either
 * two subsequent newlines (thus a whiteline in between as can be seen in this
 * example), or when the Summary ends with a dot (`.`) and some form of
 * whitespace.
 */
DOCCOMMENT;

$factory  = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);

// Should contain the first line of the DocBlock
$summary = $docblock->getSummary();

// Contains an object of type Description; you can either cast it to string or use
// the render method to get a string representation of the Description.
//
// In subsequent examples we will be fiddling a bit more with the Description.
$description = $docblock->getDescription();