1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\AliasLoader; |
6
|
|
|
use Illuminate\Support\Facades\App; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
|
9
|
|
|
class LocalEnvironmentServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Service Providers only should be loaded in development. |
13
|
|
|
* |
14
|
|
|
* @var array |
15
|
|
|
*/ |
16
|
|
|
protected $localProviders = [ |
17
|
|
|
\Barryvdh\Debugbar\ServiceProvider::class, |
18
|
|
|
\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, |
19
|
|
|
\Laravel\Tinker\TinkerServiceProvider::class, |
20
|
|
|
]; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Facade aliases only should be loaded in development. |
24
|
|
|
* |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
protected $facadeAliases = [ |
28
|
|
|
'Debugbar' => \Barryvdh\Debugbar\Facade::class, |
29
|
|
|
]; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Register Service Providers. |
33
|
|
|
*/ |
34
|
|
|
protected function registerServiceProviders() |
35
|
|
|
{ |
36
|
|
|
foreach ($this->localProviders as $provider) { |
37
|
|
|
$this->app->register($provider); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register Facade aliases |
43
|
|
|
* Base file Alias load is /config/app.php => aliases. |
44
|
|
|
*/ |
45
|
|
|
public function registerFacadeAliases() |
46
|
|
|
{ |
47
|
|
|
$loader = AliasLoader::getInstance(); |
48
|
|
|
foreach ($this->facadeAliases as $alias => $facade) { |
49
|
|
|
$loader->alias($alias, $facade); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Register the specific service prodiders and facade aliases only if in .env file APP_ENV = local. |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
public function boot() |
59
|
|
|
{ |
60
|
|
|
if (App::environment('local')) { |
|
|
|
|
61
|
|
|
$this->registerServiceProviders(); |
62
|
|
|
$this->registerFacadeAliases(); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Register the application services. |
68
|
|
|
* |
69
|
|
|
* @return void |
70
|
|
|
*/ |
71
|
|
|
public function register() |
72
|
|
|
{ |
73
|
|
|
// |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.