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 DocBlock\Tag[] $tags |
||
44 | * @param Types\Context $context The context in which the DocBlock occurs. |
||
45 | * @param Location $location The location within the file that this DocBlock occurs in. |
||
46 | */ |
||
47 | public function __construct( |
||
70 | 12 | ||
71 | 12 | public function getSummary(): string |
|
75 | 12 | ||
76 | /** |
||
77 | * @return DocBlock\Description |
||
78 | */ |
||
79 | public function getDescription(): DocBlock\Description |
||
83 | |||
84 | /** |
||
85 | * Returns the current context. |
||
86 | * |
||
87 | */ |
||
88 | 1 | public function getContext(): Types\Context |
|
92 | |||
93 | /** |
||
94 | * Returns the current location. |
||
95 | */ |
||
96 | public function getLocation(): ?Location |
||
100 | 1 | ||
101 | /** |
||
102 | * Returns whether this DocBlock is the start of a Template section. |
||
103 | * |
||
104 | * A Docblock may serve as template for a series of subsequent DocBlocks. This is indicated by a special marker |
||
105 | * (`#@+`) that is appended directly after the opening `/**` of a DocBlock. |
||
106 | * |
||
107 | * An example of such an opening is: |
||
108 | 1 | * |
|
109 | * ``` |
||
110 | 1 | * /**#@+ |
|
111 | * * My DocBlock |
||
112 | * * / |
||
113 | * ``` |
||
114 | * |
||
115 | * The description and tags (not the summary!) are copied onto all subsequent DocBlocks and also applied to all |
||
116 | * elements that follow until another DocBlock is found that contains the closing marker (`#@-`). |
||
117 | * |
||
118 | * @see self::isTemplateEnd() for the check whether a closing marker was provided. |
||
119 | * |
||
120 | */ |
||
121 | public function isTemplateStart(): bool |
||
125 | |||
126 | /** |
||
127 | * Returns whether this DocBlock is the end of a Template section. |
||
128 | * |
||
129 | * @see self::isTemplateStart() for a more complete description of the Docblock Template functionality. |
||
130 | * |
||
131 | */ |
||
132 | public function isTemplateEnd(): bool |
||
136 | 1 | ||
137 | /** |
||
138 | * Returns the tags for this DocBlock. |
||
139 | * |
||
140 | * @return Tag[] |
||
141 | */ |
||
142 | public function getTags() |
||
146 | 1 | ||
147 | /** |
||
148 | 1 | * Returns an array of tags matching the given name. If no tags are found |
|
149 | * an empty array is returned. |
||
150 | * |
||
151 | * @param string $name String to search by. |
||
152 | * |
||
153 | * @return Tag[] |
||
154 | */ |
||
155 | public function getTagsByName(string $name) |
||
170 | |||
171 | 2 | /** |
|
172 | * Checks if a tag of a certain type is present in this DocBlock. |
||
173 | 1 | * |
|
174 | * @param string $name Tag name to check for. |
||
175 | */ |
||
176 | 1 | public function hasTag(string $name): bool |
|
187 | |||
188 | /** |
||
189 | * Remove a tag from this DocBlock. |
||
190 | * |
||
191 | * @param Tag $tag The tag to remove. |
||
|
|||
192 | */ |
||
193 | public function removeTag(Tag $tagToRemove): void |
||
202 | |||
203 | /** |
||
204 | * Adds a tag to this DocBlock. |
||
205 | 1 | * |
|
206 | * @param Tag $tag The tag to add. |
||
207 | */ |
||
208 | private function addTag(Tag $tag): void |
||
212 | } |
||
213 |
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.