1 | <?php |
||
20 | class DocCommentParser |
||
21 | { |
||
22 | /** |
||
23 | * @var string The description as found in the doc comment |
||
24 | */ |
||
25 | protected $description = ''; |
||
26 | |||
27 | /** |
||
28 | * @var array An array of tag names and their values (multiple values are possible) |
||
29 | */ |
||
30 | protected $tags = []; |
||
31 | |||
32 | /** |
||
33 | * Parses the given doc comment and saves the result (description and |
||
34 | * tags) in the parser's object. They can be retrieved by the |
||
35 | * getTags() getTagValues() and getDescription() methods. |
||
36 | * |
||
37 | * @param string $docComment A doc comment as returned by the reflection getDocComment() method |
||
38 | */ |
||
39 | public function parseDocComment($docComment) |
||
53 | |||
54 | /** |
||
55 | * Returns the tags which have been previously parsed |
||
56 | * |
||
57 | * @return array Array of tag names and their (multiple) values |
||
58 | */ |
||
59 | public function getTagsValues() |
||
63 | |||
64 | /** |
||
65 | * Returns the values of the specified tag. The doc comment |
||
66 | * must be parsed with parseDocComment() before tags are |
||
67 | * available. |
||
68 | * |
||
69 | * @param string $tagName The tag name to retrieve the values for |
||
70 | * @throws \RuntimeException |
||
71 | * @return array The tag's values |
||
72 | */ |
||
73 | public function getTagValues($tagName) |
||
80 | |||
81 | /** |
||
82 | * Checks if a tag with the given name exists |
||
83 | * |
||
84 | * @param string $tagName The tag name to check for |
||
85 | * @return bool TRUE the tag exists, otherwise FALSE |
||
86 | */ |
||
87 | public function isTaggedWith($tagName) |
||
91 | |||
92 | /** |
||
93 | * Returns the description which has been previously parsed |
||
94 | * |
||
95 | * @return string The description which has been parsed |
||
96 | */ |
||
97 | public function getDescription() |
||
101 | |||
102 | /** |
||
103 | * Parses a line of a doc comment for a tag and its value. |
||
104 | * The result is stored in the interal tags array. |
||
105 | * |
||
106 | * @param string $line A line of a doc comment which starts with an @-sign |
||
107 | */ |
||
108 | protected function parseTag($line) |
||
118 | } |
||
119 |