|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Facade\Ignition\SolutionProviders; |
|
4
|
|
|
|
|
5
|
|
|
use Throwable; |
|
6
|
|
|
use LogicException; |
|
7
|
|
|
use Facade\IgnitionContracts\BaseSolution; |
|
8
|
|
|
use Facade\IgnitionContracts\HasSolutionsForThrowable; |
|
9
|
|
|
|
|
10
|
|
|
class RedisClientNotInstalledSolutionProvider implements HasSolutionsForThrowable |
|
11
|
|
|
{ |
|
12
|
|
|
public function canSolve(Throwable $throwable): bool |
|
13
|
|
|
{ |
|
14
|
|
|
if (! $throwable instanceof LogicException && ! $throwable instanceof ViewException) { |
|
|
|
|
|
|
15
|
|
|
return false; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
return true; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function getSolutions(Throwable $throwable): array |
|
22
|
|
|
{ |
|
23
|
|
|
$client = config('database.redis.client'); |
|
24
|
|
|
[$message, $description] = $this->getSolutionMessage($client); |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
return [ |
|
27
|
|
|
BaseSolution::create($message) |
|
28
|
|
|
->setSolutionDescription($description), |
|
29
|
|
|
]; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
protected function getSolutionMessage(string $client): array |
|
33
|
|
|
{ |
|
34
|
|
|
$predis = file_exists(base_path('vendor/predis/predis')); |
|
35
|
|
|
$phpredis = file_exists(base_path('vendor/phpredis/phpredis')); |
|
36
|
|
|
|
|
37
|
|
|
if ($client === 'predis') { |
|
38
|
|
|
if ($predis === false && $phpredis === true) { |
|
39
|
|
|
return [ |
|
40
|
|
|
'predis is set as client, but it wasn\'t installed.', |
|
41
|
|
|
'either run `composer require predis/predis` or default to phpredis which is installed', |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if ($predis === true && $phpredis === false) { |
|
47
|
|
|
return [ |
|
48
|
|
|
'phpredis is set as client, but it wasn\'t installed.', |
|
49
|
|
|
'either run `composer require phpredis/phpredis` or set the `REDIS_CLIENT` to predis in your `.env`.', |
|
50
|
|
|
]; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
return [ |
|
54
|
|
|
'there was no client installed.', |
|
55
|
|
|
'run `composer require phpredis/phpredis`', |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto 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
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.