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