Conditions | 5 |
Paths | 1 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace Spatie\CollectionMacros\Macros; |
||
18 | public function sectionBy() |
||
19 | { |
||
20 | return function ($key, bool $preserveKeys = false, $sectionKey = 0, $itemsKey = 1): Collection { |
||
21 | $sectionNameRetriever = $this->valueRetriever($key); |
||
22 | |||
23 | $results = new Collection(); |
||
24 | |||
25 | foreach ($this->items as $key => $value) { |
||
26 | $sectionName = $sectionNameRetriever($value); |
||
27 | |||
28 | if (! $results->last() || $results->last()->get($sectionKey) !== $sectionName) { |
||
29 | $results->push(new Collection([ |
||
30 | $sectionKey => $sectionName, |
||
31 | $itemsKey => new Collection(), |
||
32 | ])); |
||
33 | } |
||
34 | |||
35 | $results->last()->get($itemsKey)->offsetSet($preserveKeys ? $key : null, $value); |
||
36 | } |
||
37 | |||
38 | return $results; |
||
39 | }; |
||
40 | } |
||
41 | } |
||
42 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.