1 | <?php declare(strict_types=1); |
||
19 | final class DocBlock |
||
20 | { |
||
21 | /** @var string The opening line for this docblock. */ |
||
22 | private $summary = ''; |
||
23 | |||
24 | /** @var DocBlock\Description The actual description for this docblock. */ |
||
25 | private $description = null; |
||
26 | |||
27 | /** @var Tag[] An array containing all the tags in this docblock; except inline. */ |
||
28 | private $tags = []; |
||
29 | |||
30 | /** @var Types\Context Information about the context of this DocBlock. */ |
||
31 | private $context = null; |
||
32 | |||
33 | /** @var Location Information about the location of this DocBlock. */ |
||
34 | private $location = null; |
||
35 | |||
36 | /** @var bool Is this DocBlock (the start of) a template? */ |
||
37 | private $isTemplateStart = false; |
||
38 | |||
39 | /** @var bool Does this DocBlock signify the end of a DocBlock template? */ |
||
40 | private $isTemplateEnd = false; |
||
41 | |||
42 | /** |
||
43 | * @param string $summary |
||
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( |
|
73 | 12 | ||
74 | 12 | /** |
|
75 | 12 | * @return string |
|
76 | */ |
||
77 | public function getSummary(): string |
||
81 | |||
82 | 1 | /** |
|
83 | * @return DocBlock\Description |
||
84 | */ |
||
85 | public function getDescription(): DocBlock\Description |
||
89 | |||
90 | 1 | /** |
|
91 | * Returns the current context. |
||
92 | * |
||
93 | * @return Types\Context |
||
94 | */ |
||
95 | public function getContext(): Types\Context |
||
99 | |||
100 | 1 | /** |
|
101 | * Returns the current location. |
||
102 | */ |
||
103 | public function getLocation(): ?Location |
||
107 | |||
108 | 1 | /** |
|
109 | * Returns whether this DocBlock is the start of a Template section. |
||
110 | 1 | * |
|
111 | * A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker |
||
112 | * (`#@+`) that is appended directly after the opening `/**` of a DocBlock. |
||
113 | * |
||
114 | * An example of such an opening is: |
||
115 | * |
||
116 | * ``` |
||
117 | * /**#@+ |
||
118 | * * My DocBlock |
||
119 | * * / |
||
120 | * ``` |
||
121 | * |
||
122 | * The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all |
||
123 | * elements that follow until another DocBlock is found that contains the closing marker (`#@-`). |
||
124 | * |
||
125 | * @see self::isTemplateEnd() for the check whether a closing marker was provided. |
||
126 | * |
||
127 | * @return boolean |
||
128 | */ |
||
129 | public function isTemplateStart(): bool |
||
133 | |||
134 | 1 | /** |
|
135 | * Returns whether this DocBlock is the end of a Template section. |
||
136 | 1 | * |
|
137 | * @see self::isTemplateStart() for a more complete description of the Docblock Template functionality. |
||
138 | * |
||
139 | * @return boolean |
||
140 | */ |
||
141 | public function isTemplateEnd(): bool |
||
145 | |||
146 | 1 | /** |
|
147 | * Returns the tags for this DocBlock. |
||
148 | 1 | * |
|
149 | * @return Tag[] |
||
150 | */ |
||
151 | public function getTags() |
||
155 | |||
156 | 1 | /** |
|
157 | * Returns an array of tags matching the given name. If no tags are found |
||
158 | 1 | * an empty array is returned. |
|
159 | * |
||
160 | * @param string $name String to search by. |
||
161 | * |
||
162 | * @return Tag[] |
||
163 | */ |
||
164 | public function getTagsByName(string $name) |
||
179 | |||
180 | /** |
||
181 | 1 | * Checks if a tag of a certain type is present in this DocBlock. |
|
182 | * |
||
183 | * @param string $name Tag name to check for. |
||
184 | 1 | * |
|
185 | * @return bool |
||
186 | */ |
||
187 | public function hasTag(string $name): bool |
||
198 | |||
199 | 1 | /** |
|
200 | 1 | * Remove a tag from this DocBlock. |
|
201 | 1 | * |
|
202 | * @param Tag $tag The tag to remove. |
||
|
|||
203 | * |
||
204 | */ |
||
205 | 1 | public function removeTag(Tag $tagToRemove) |
|
214 | |||
215 | 1 | /** |
|
216 | * Adds a tag to this DocBlock. |
||
217 | 1 | * |
|
218 | 1 | * @param Tag $tag The tag to add. |
|
219 | 1 | * |
|
220 | 1 | */ |
|
221 | private function addTag(Tag $tag) |
||
225 | } |
||
226 |
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.