These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Spatie\CollectionMacros\Macros; |
||
4 | |||
5 | use Illuminate\Support\Collection; |
||
6 | |||
7 | /** |
||
8 | * Transpose an array. |
||
9 | * |
||
10 | * @mixin \Illuminate\Support\Collection |
||
11 | * |
||
12 | * @return \Illuminate\Support\Collection |
||
13 | * |
||
14 | * @throws \LengthException |
||
15 | */ |
||
16 | class Transpose |
||
17 | { |
||
18 | public function __invoke() |
||
19 | { |
||
20 | return function (): Collection { |
||
21 | if ($this->isEmpty()) { |
||
22 | return new static(); |
||
23 | } |
||
24 | |||
25 | $firstItem = $this->first(); |
||
26 | |||
27 | $expectedLength = is_array($firstItem) || $firstItem instanceof Countable ? count($firstItem) : 0; |
||
0 ignored issues
–
show
|
|||
28 | |||
29 | array_walk($this->items, function ($row) use ($expectedLength) { |
||
30 | if ((is_array($row) || $row instanceof Countable) && count($row) !== $expectedLength) { |
||
0 ignored issues
–
show
The class
Spatie\CollectionMacros\Macros\Countable does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed.
Loading history...
|
|||
31 | throw new \LengthException("Element's length must be equal."); |
||
32 | } |
||
33 | }); |
||
34 | |||
35 | $items = array_map(function (...$items) { |
||
36 | return new static($items); |
||
37 | }, ...array_map(function ($items) { |
||
38 | return $this->getArrayableItems($items); |
||
39 | }, array_values($this->items))); |
||
40 | |||
41 | return new static($items); |
||
42 | }; |
||
43 | } |
||
44 | } |
||
45 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.