1 | <?php |
||
18 | final class DocBlock |
||
19 | { |
||
20 | /** @var string The opening line for this docblock. */ |
||
21 | private $summary = ''; |
||
22 | |||
23 | /** @var DocBlock\Description The actual description for this docblock. */ |
||
24 | private $description = null; |
||
25 | |||
26 | /** @var Tag[] An array containing all the tags in this docblock; except inline. */ |
||
27 | private $tags = []; |
||
28 | |||
29 | /** @var Types\Context Information about the context of this DocBlock. */ |
||
30 | private $context = null; |
||
31 | |||
32 | /** @var Location Information about the location of this DocBlock. */ |
||
33 | private $location = null; |
||
34 | |||
35 | /** @var bool Is this DocBlock (the start of) a template? */ |
||
36 | private $isTemplateStart = false; |
||
37 | |||
38 | /** @var bool Does this DocBlock signify the end of a DocBlock template? */ |
||
39 | private $isTemplateEnd = false; |
||
40 | |||
41 | /** |
||
42 | * @param string $summary |
||
43 | * @param DocBlock\Description $description |
||
44 | * @param DocBlock\Tag[] $tags |
||
45 | * @param Types\Context $context The context in which the DocBlock occurs. |
||
46 | * @param Location $location The location within the file that this DocBlock occurs in. |
||
47 | * @param bool $isTemplateStart |
||
48 | * @param bool $isTemplateEnd |
||
49 | */ |
||
50 | 16 | public function __construct( |
|
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | 1 | public function getSummary() |
|
84 | |||
85 | /** |
||
86 | * @return DocBlock\Description |
||
87 | */ |
||
88 | 1 | public function getDescription() |
|
92 | |||
93 | /** |
||
94 | * Returns the current context. |
||
95 | * |
||
96 | * @return Types\Context |
||
97 | */ |
||
98 | 1 | public function getContext() |
|
102 | |||
103 | /** |
||
104 | * Returns the current location. |
||
105 | * |
||
106 | * @return Location |
||
107 | */ |
||
108 | 1 | public function getLocation() |
|
112 | |||
113 | /** |
||
114 | * Returns whether this DocBlock is the start of a Template section. |
||
115 | * |
||
116 | * A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker |
||
117 | * (`#@+`) that is appended directly after the opening `/**` of a DocBlock. |
||
118 | * |
||
119 | * An example of such an opening is: |
||
120 | * |
||
121 | * ``` |
||
122 | * /**#@+ |
||
123 | * * My DocBlock |
||
124 | * * / |
||
125 | * ``` |
||
126 | * |
||
127 | * The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all |
||
128 | * elements that follow until another DocBlock is found that contains the closing marker (`#@-`). |
||
129 | * |
||
130 | * @see self::isTemplateEnd() for the check whether a closing marker was provided. |
||
131 | * |
||
132 | * @return boolean |
||
133 | */ |
||
134 | 1 | public function isTemplateStart() |
|
138 | |||
139 | /** |
||
140 | * Returns whether this DocBlock is the end of a Template section. |
||
141 | * |
||
142 | * @see self::isTemplateStart() for a more complete description of the Docblock Template functionality. |
||
143 | * |
||
144 | * @return boolean |
||
145 | */ |
||
146 | 1 | public function isTemplateEnd() |
|
150 | |||
151 | /** |
||
152 | * Returns the tags for this DocBlock. |
||
153 | * |
||
154 | * @return Tag[] |
||
155 | */ |
||
156 | 1 | public function getTags() |
|
160 | |||
161 | /** |
||
162 | * Returns an array of tags matching the given name. If no tags are found |
||
163 | * an empty array is returned. |
||
164 | * |
||
165 | * @param string $name String to search by. |
||
166 | * |
||
167 | * @return Tag[] |
||
168 | */ |
||
169 | 2 | public function getTagsByName($name) |
|
186 | |||
187 | /** |
||
188 | * Checks if a tag of a certain type is present in this DocBlock. |
||
189 | * |
||
190 | * @param string $name Tag name to check for. |
||
191 | * |
||
192 | * @return bool |
||
193 | */ |
||
194 | 2 | public function hasTag($name) |
|
207 | |||
208 | /** |
||
209 | * Remove a tag from this DocBlock. |
||
210 | * |
||
211 | * @param Tag $tag The tag to remove. |
||
|
|||
212 | * |
||
213 | * @return void |
||
214 | */ |
||
215 | 1 | public function removeTag(Tag $tagToRemove) |
|
216 | { |
||
217 | 1 | foreach ($this->tags as $key => $tag) { |
|
218 | 1 | if ($tag === $tagToRemove) { |
|
219 | 1 | unset($this->tags[$key]); |
|
220 | 1 | break; |
|
221 | } |
||
222 | } |
||
223 | 1 | } |
|
224 | |||
225 | /** |
||
226 | * Adds a tag to this DocBlock. |
||
227 | * |
||
228 | * @param Tag $tag The tag to add. |
||
229 | * |
||
230 | * @return void |
||
231 | */ |
||
232 | 4 | private function addTag(Tag $tag) |
|
236 | } |
||
237 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.