Conditions | 5 |
Paths | 1 |
Total Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function sliceBefore() |
||
18 | { |
||
19 | return function ($callback, bool $preserveKeys = false): Collection { |
||
20 | if ($this->isEmpty()) { |
||
21 | return new static(); |
||
22 | } |
||
23 | |||
24 | if (! $preserveKeys) { |
||
25 | $sliced = new static([ |
||
26 | new static([$this->first()]), |
||
27 | ]); |
||
28 | |||
29 | return $this->eachCons(2)->reduce(function ($sliced, $previousAndCurrent) use ($callback) { |
||
30 | list($previousItem, $item) = $previousAndCurrent; |
||
31 | |||
32 | $callback($item, $previousItem) ? $sliced->push(new static([$item])) : $sliced->last()->push($item); |
||
33 | |||
34 | return $sliced; |
||
35 | }, $sliced); |
||
36 | } |
||
37 | |||
38 | $sliced = new static([$this->take(1)]); |
||
39 | |||
40 | return $this->eachCons(2, $preserveKeys)->reduce(function ($sliced, $previousAndCurrent) use ($callback) { |
||
41 | $previousItem = $previousAndCurrent->take(1); |
||
42 | $item = $previousAndCurrent->take(-1); |
||
43 | |||
44 | $itemKey = $item->keys()->first(); |
||
45 | $valuesItem = $item->first(); |
||
46 | $valuesPreviousItem = $previousItem->first(); |
||
47 | |||
48 | $callback($valuesItem, $valuesPreviousItem) ? $sliced->push($item) : $sliced->last() |
||
49 | ->put($itemKey, $valuesItem); |
||
50 | |||
51 | return $sliced; |
||
52 | }, $sliced); |
||
53 | }; |
||
54 | } |
||
55 | } |
||
56 |
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.