Total Complexity | 5 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | trait SplTypeTrait |
||
18 | { |
||
19 | /** |
||
20 | * Internal enum value. |
||
21 | * |
||
22 | * @var mixed |
||
23 | */ |
||
24 | // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore |
||
25 | protected $__default; |
||
26 | |||
27 | /** |
||
28 | * Serialize object. |
||
29 | * |
||
30 | * @return array<string,mixed> |
||
31 | */ |
||
32 | final public function __serialize(): array |
||
33 | { |
||
34 | return [ |
||
35 | '__default' => $this->__default, |
||
36 | ]; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Unserialize object. |
||
41 | * |
||
42 | * @param array<string,mixed> $data |
||
43 | * @return void |
||
44 | */ |
||
45 | final public function __unserialize(array $data): void |
||
46 | { |
||
47 | $this->__default = $data['__default']; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Stringify object. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | final public function __toString(): string |
||
56 | { |
||
57 | return (string) $this->__default; |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Export object. |
||
62 | * |
||
63 | * @param array<mixed,mixed> $properties |
||
64 | * |
||
65 | * @return SplType |
||
66 | */ |
||
67 | final public static function __set_state(array $properties): object |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Dumping object. |
||
74 | * |
||
75 | * @return array<string,mixed> |
||
76 | */ |
||
77 | final public function __debugInfo(): array |
||
81 | ]; |
||
82 | } |
||
83 | } |
||
84 |
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.