1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Laravel WuBook. |
5
|
|
|
* |
6
|
|
|
* (c) Filippo Galante <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace IlGala\LaravelWubook; |
13
|
|
|
|
14
|
|
|
use Illuminate\Contracts\Container\Container; |
15
|
|
|
use Illuminate\Foundation\Application as LaravelApplication; |
16
|
|
|
use Illuminate\Support\ServiceProvider; |
17
|
|
|
use Laravel\Lumen\Application as LumenApplication; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* This is the WuBook service provider class. |
21
|
|
|
* |
22
|
|
|
* @author Filippo Galante <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class WuBookServiceProvider extends ServiceProvider |
25
|
|
|
{ |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Boot the service provider. |
29
|
|
|
* |
30
|
|
|
* @return void |
31
|
|
|
*/ |
32
|
|
|
public function boot() |
33
|
|
|
{ |
34
|
|
|
$this->setupConfig(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Setup the config. |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
protected function setupConfig() |
43
|
|
|
{ |
44
|
|
|
$source = realpath(__DIR__ . '/../config/wubook.php'); |
45
|
|
|
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { |
|
|
|
|
46
|
|
|
$this->publishes([$source => config_path('wubook.php')]); |
47
|
|
|
} elseif ($this->app instanceof LumenApplication) { |
|
|
|
|
48
|
|
|
$this->app->configure('wubook'); |
49
|
|
|
} |
50
|
|
|
$this->mergeConfigFrom($source, 'wubook'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Register the service provider. |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
public function register() |
59
|
|
|
{ |
60
|
|
|
$this->app->singleton('wubook', function (Container $app) { |
61
|
|
|
$config = $app['config']; |
62
|
|
|
return new WuBookManager($config); |
63
|
|
|
}); |
64
|
|
|
|
65
|
|
|
$this->app->alias('wubook', WuBookManager::class); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the services provided by the provider. |
70
|
|
|
* |
71
|
|
|
* @return string[] |
72
|
|
|
*/ |
73
|
|
|
public function provides() |
74
|
|
|
{ |
75
|
|
|
return [ |
76
|
|
|
'wubook', |
77
|
|
|
]; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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.