| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | trait TransformMethodsTrait |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * Run a map over each of the items. |
||
| 16 | * |
||
| 17 | * @param callable $callback |
||
| 18 | * @return static |
||
| 19 | */ |
||
| 20 | public function map(callable $callback) |
||
| 21 | { |
||
| 22 | $keys = array_keys($this->items); |
||
| 23 | |||
| 24 | $items = array_map($callback, $this->items, $keys); |
||
| 25 | |||
| 26 | return new static(array_combine($keys, $items)); |
||
|
|
|||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return array |
||
| 31 | */ |
||
| 32 | public function toArray() |
||
| 33 | { |
||
| 34 | return array_map(function ($value) { |
||
| 35 | return $value instanceof AbstractCollection ? $value->toArray() : $value; |
||
| 36 | }, $this->items); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Specify data which should be serialized to JSON |
||
| 41 | * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
||
| 42 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
| 43 | * which is a value of any type other than a resource. |
||
| 44 | * @since 5.4.0 |
||
| 45 | */ |
||
| 46 | public function jsonSerialize() |
||
| 55 | } |
||
| 56 | } |
||
| 57 |
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.