Total Complexity | 9 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
15 | class Method implements HasVisibility |
||
16 | { |
||
17 | use ProvidesVisibility; |
||
18 | |||
19 | /** @var string */ |
||
20 | private $name; |
||
21 | |||
22 | /** @var Variable[] */ |
||
23 | private $parameters; |
||
24 | |||
25 | 126 | private function __construct(string $name, Visibility $modifier, array $params = []) |
|
26 | { |
||
27 | 126 | $this->name = $name; |
|
28 | 126 | $this->modifier = $modifier; |
|
29 | 126 | $this->parameters = $params; |
|
30 | 126 | } |
|
31 | |||
32 | 123 | public static function public(string $name, array $params = []): Method |
|
33 | { |
||
34 | 123 | return new Method($name, Visibility::public(), $params); |
|
35 | } |
||
36 | |||
37 | 15 | public static function protected(string $name, array $params = []): Method |
|
38 | { |
||
39 | 15 | return new Method($name, Visibility::protected(), $params); |
|
40 | } |
||
41 | |||
42 | 45 | public static function private(string $name, array $params = []): Method |
|
43 | { |
||
44 | 45 | return new Method($name, Visibility::private(), $params); |
|
45 | } |
||
46 | |||
47 | 36 | public function isConstructor(): bool |
|
50 | } |
||
51 | |||
52 | 3 | public function name(): string |
|
53 | { |
||
54 | 3 | return $this->name; |
|
55 | } |
||
56 | |||
57 | 30 | public function parameters(): array |
|
58 | { |
||
59 | 30 | return $this->parameters; |
|
60 | } |
||
61 | |||
62 | 48 | public function __toString() |
|
69 | ); |
||
70 | } |
||
71 | } |
||
72 |
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. Please note the @ignore annotation hint above.