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 ViewComponents\Eloquent; |
||
4 | |||
5 | use ArrayIterator; |
||
6 | use Illuminate\Database\Eloquent\Builder as EloquentBuilder; |
||
7 | use Illuminate\Database\Query\Builder; |
||
8 | use RuntimeException; |
||
9 | use Traversable; |
||
10 | use ViewComponents\ViewComponents\Data\ProcessingService\AbstractProcessingService; |
||
11 | |||
12 | /** |
||
13 | * Class DbTableProcessingManager. |
||
14 | */ |
||
15 | class EloquentProcessingService extends AbstractProcessingService |
||
16 | { |
||
17 | /** |
||
18 | * @param Builder|EloquentBuilder $data |
||
19 | * @return Traversable |
||
20 | */ |
||
21 | protected function afterOperations($data) |
||
22 | { |
||
23 | if ($data instanceof EloquentBuilder) { |
||
0 ignored issues
–
show
|
|||
24 | return $data->get(); |
||
25 | } elseif ($data instanceof Builder) { |
||
0 ignored issues
–
show
The class
Illuminate\Database\Query\Builder 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...
|
|||
26 | return new ArrayIterator($data->get()); |
||
27 | } |
||
28 | throw new RuntimeException('Unsupported type of data source.'); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param Builder|EloquentBuilder $data |
||
33 | * @return Builder|EloquentBuilder |
||
34 | */ |
||
35 | protected function beforeOperations($data) |
||
36 | { |
||
37 | return clone $data; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return int |
||
42 | */ |
||
43 | public function count() |
||
44 | { |
||
45 | return $this->applyOperations( |
||
46 | $this->beforeOperations($this->dataSource) |
||
47 | )->count(); |
||
48 | } |
||
49 | } |
||
50 |
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.