1 | <?php |
||
9 | trait GenericCollection |
||
10 | { |
||
11 | /** |
||
12 | * Returns whether the collection is empty. |
||
13 | * |
||
14 | * This should be equivalent to a count of zero, but is not required. |
||
15 | * Implementations should define what empty means in their own context. |
||
16 | * |
||
17 | * @return bool whether the collection is empty. |
||
18 | */ |
||
19 | 156 | public function isEmpty(): bool |
|
23 | |||
24 | /** |
||
25 | * Returns a representation that can be natively converted to JSON, which is |
||
26 | * called when invoking json_encode. |
||
27 | * |
||
28 | * @return mixed |
||
29 | * |
||
30 | * @see JsonSerializable |
||
31 | */ |
||
32 | 34 | public function jsonSerialize() |
|
36 | |||
37 | /** |
||
38 | * Creates a shallow copy of the collection. |
||
39 | * |
||
40 | * @return Collection a shallow copy of the collection. |
||
41 | */ |
||
42 | 52 | public function copy(): Collection |
|
46 | |||
47 | /** |
||
48 | * Returns an array representation of the collection. |
||
49 | * |
||
50 | * The format of the returned array is implementation-dependent. Some |
||
51 | * implementations may throw an exception if an array representation |
||
52 | * could not be created (for example when object are used as keys). |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | abstract public function toArray(): array; |
||
57 | |||
58 | /** |
||
59 | * Invoked when calling var_dump. |
||
60 | * |
||
61 | * @return array |
||
62 | */ |
||
63 | 29 | public function __debugInfo() |
|
67 | |||
68 | /** |
||
69 | * Returns a string representation of the collection, which is invoked when |
||
70 | * the collection is converted to a string. |
||
71 | */ |
||
72 | 87 | public function __toString() |
|
76 | } |
||
77 |
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.