1 | <?php declare(strict_types = 1); |
||
25 | class ClassDefinition extends AbstractDefinition implements ClassBuilderInterface |
||
26 | { |
||
27 | /** @var string Class name with namespace */ |
||
28 | protected $className; |
||
29 | /** @var string Class name space */ |
||
30 | protected $nameSpace; |
||
31 | /** @var string Service name */ |
||
32 | protected $serviceName; |
||
33 | /** @var array Class container scopes */ |
||
34 | protected $scopes = []; |
||
35 | /** @var bool Is singleton */ |
||
36 | protected $isSingleton = false; |
||
37 | /** @var bool Is class definition was analyzed */ |
||
38 | protected $isAnalyzed = false; |
||
39 | |||
40 | /** @var MethodDefinition[] Methods collection */ |
||
41 | protected $methodsCollection = []; |
||
42 | /** @var PropertyDefinition[] Property collection */ |
||
43 | protected $propertiesCollection = []; |
||
44 | |||
45 | /** {@inheritdoc} */ |
||
46 | 9 | public function defineConstructor(): MethodBuilderInterface |
|
51 | |||
52 | /** {@inheritdoc} */ |
||
53 | 13 | public function defineMethod(string $methodName): MethodBuilderInterface |
|
66 | |||
67 | /** {@inheritdoc} */ |
||
68 | 9 | public function defineProperty(string $propertyName): PropertyBuilderInterface |
|
81 | |||
82 | /** {@inheritdoc} */ |
||
83 | 2 | public function defineIsPrototype(): ClassBuilderInterface |
|
89 | |||
90 | /** {@inheritdoc} */ |
||
91 | 2 | public function defineIsSingleton(): ClassBuilderInterface |
|
97 | |||
98 | /** |
||
99 | * Get namespace |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | 2 | public function getNameSpace(): string |
|
107 | |||
108 | /** |
||
109 | * @param string $nameSpace |
||
110 | * @return ClassDefinition |
||
111 | */ |
||
112 | 6 | public function setNameSpace(string $nameSpace): ClassDefinition |
|
118 | |||
119 | /** |
||
120 | * Add scope to definition |
||
121 | * |
||
122 | * @param AbstractScope $scope |
||
123 | * @return ClassDefinition |
||
124 | * @throws ScopeAlreadyExistsException |
||
125 | */ |
||
126 | 4 | public function addScope(AbstractScope $scope): ClassDefinition |
|
136 | |||
137 | /** |
||
138 | * Remove scope from definition |
||
139 | * |
||
140 | * @param string $id |
||
141 | * @return ClassDefinition |
||
142 | * @throws ScopeNotFoundException |
||
143 | */ |
||
144 | 2 | public function removeScope(string $id): ClassDefinition |
|
154 | |||
155 | /** |
||
156 | * Check if scope exists in definition |
||
157 | * |
||
158 | * @param string $id |
||
159 | * @return bool |
||
160 | */ |
||
161 | 4 | public function hasScope(string $id): bool |
|
165 | |||
166 | /** |
||
167 | * Get scope from definition |
||
168 | * |
||
169 | * @param string $id |
||
170 | * @return mixed |
||
171 | * @throws ScopeNotFoundException |
||
172 | */ |
||
173 | 2 | public function getScope(string $id): AbstractScope |
|
180 | |||
181 | /** |
||
182 | * Get all scopes |
||
183 | * |
||
184 | * @return AbstractScope[] |
||
185 | */ |
||
186 | 3 | public function getScopes(): array |
|
190 | |||
191 | /** |
||
192 | * Get class name |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | 8 | public function getClassName(): string |
|
200 | |||
201 | /** |
||
202 | * @param string|ClassReference $className |
||
203 | * @return ClassDefinition |
||
204 | * @throws \InvalidArgumentException |
||
205 | */ |
||
206 | 28 | public function setClassName($className): ClassDefinition |
|
218 | |||
219 | /** |
||
220 | * @return string|null |
||
221 | */ |
||
222 | 3 | public function getServiceName() |
|
226 | |||
227 | /** |
||
228 | * @param string $serviceName |
||
229 | * @return ClassDefinition |
||
230 | */ |
||
231 | 2 | public function setServiceName(string $serviceName): ClassDefinition |
|
237 | |||
238 | /** |
||
239 | * @return boolean |
||
240 | */ |
||
241 | 4 | public function isSingleton(): bool |
|
245 | |||
246 | /** |
||
247 | * @param boolean $isSingleton |
||
248 | * @return ClassDefinition |
||
249 | */ |
||
250 | 1 | public function setIsSingleton(bool $isSingleton): ClassDefinition |
|
256 | |||
257 | /** |
||
258 | * @return PropertyDefinition[] |
||
259 | */ |
||
260 | 4 | public function getPropertiesCollection(): array |
|
264 | |||
265 | /** |
||
266 | * @return MethodDefinition[] |
||
267 | */ |
||
268 | 4 | public function getMethodsCollection(): array |
|
272 | |||
273 | /** |
||
274 | * Get existing or define new method |
||
275 | * |
||
276 | * @param string $methodName |
||
277 | * @return MethodDefinition |
||
278 | * @throws MethodDefinitionAlreadyExistsException |
||
279 | * @throws MethodDefinitionNotFoundException |
||
280 | */ |
||
281 | 2 | public function setupMethod(string $methodName): MethodDefinition |
|
290 | |||
291 | /** |
||
292 | * Get existing or define new property |
||
293 | * |
||
294 | * @param string $propertyName |
||
295 | * @return PropertyDefinition |
||
296 | * @throws PropertyDefinitionNotFoundException |
||
297 | * @throws PropertyDefinitionAlreadyExistsException |
||
298 | */ |
||
299 | 2 | public function setupProperty(string $propertyName): PropertyDefinition |
|
308 | |||
309 | /** |
||
310 | * Has property definition |
||
311 | * |
||
312 | * @param string $propertyName |
||
313 | * @return bool |
||
314 | */ |
||
315 | 4 | public function hasProperty(string $propertyName): bool |
|
319 | |||
320 | /** |
||
321 | * Get property definition |
||
322 | * |
||
323 | * @param $propertyName |
||
324 | * @return PropertyDefinition |
||
325 | * @throws PropertyDefinitionNotFoundException |
||
326 | */ |
||
327 | 3 | public function getProperty($propertyName): PropertyDefinition |
|
334 | |||
335 | /** |
||
336 | * Has method definition |
||
337 | * |
||
338 | * @param string $methodName |
||
339 | * @return bool |
||
340 | */ |
||
341 | 4 | public function hasMethod(string $methodName): bool |
|
345 | |||
346 | /** |
||
347 | * Get method definition |
||
348 | * |
||
349 | * @param $methodName |
||
350 | * @return MethodDefinition |
||
351 | * @throws MethodDefinitionNotFoundException |
||
352 | */ |
||
353 | 4 | public function getMethod($methodName): MethodDefinition |
|
360 | |||
361 | /** |
||
362 | * @return boolean |
||
363 | */ |
||
364 | 7 | public function isAnalyzed(): bool |
|
368 | |||
369 | /** |
||
370 | * @param boolean $isAnalyzed |
||
371 | * @return ClassDefinition |
||
372 | */ |
||
373 | 6 | public function setIsAnalyzed(bool $isAnalyzed): ClassDefinition |
|
379 | } |
||
380 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.