1 | <?php |
||
18 | class LaravelTracyServiceProvider extends ServiceProvider |
||
19 | { |
||
20 | /** |
||
21 | * Indicates if loading of the provider is deferred. |
||
22 | * |
||
23 | * @var bool |
||
24 | */ |
||
25 | protected $defer = false; |
||
26 | |||
27 | /** |
||
28 | * namespace. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $namespace = 'Recca0120\LaravelTracy\Http\Controllers'; |
||
33 | |||
34 | /** |
||
35 | * boot. |
||
36 | * |
||
37 | * @param DebuggerManager $debuggerManager |
||
|
|||
38 | * @param \Illuminate\Contracts\Http\Kernel $kernel |
||
39 | * @param \Illuminate\Contracts\View\Factory $view |
||
40 | * @param \Illuminate\Routing\Router $router |
||
41 | */ |
||
42 | 2 | public function boot(Kernel $kernel, View $view, Router $router) |
|
43 | { |
||
44 | 2 | $config = $this->app['config']['tracy']; |
|
45 | 2 | $this->handleRoutes($router, Arr::get($config, 'route', [])); |
|
46 | |||
47 | 2 | if ($this->app->runningInConsole() === true) { |
|
48 | 1 | $this->publishes([__DIR__.'/../config/tracy.php' => config_path('tracy.php')], 'config'); |
|
49 | |||
50 | 1 | return; |
|
51 | } |
||
52 | |||
53 | 1 | $view->getEngineResolver() |
|
54 | 1 | ->resolve('blade') |
|
55 | 1 | ->getCompiler() |
|
56 | ->directive('bdump', function ($expression) { |
||
57 | 1 | return "<?php \Tracy\Debugger::barDump({$expression}); ?>"; |
|
58 | 1 | }); |
|
59 | |||
60 | 1 | $enabled = Arr::get($config, 'enabled', true) === true; |
|
61 | 1 | if ($enabled === false) { |
|
62 | return; |
||
63 | } |
||
64 | |||
65 | 1 | $showException = Arr::get($config, 'showException', true); |
|
66 | 1 | if ($showException === true) { |
|
67 | $this->app->extend(ExceptionHandler::class, function ($exceptionHandler, $app) { |
||
68 | 1 | return new Handler($exceptionHandler, $app[DebuggerManager::class]); |
|
69 | 1 | }); |
|
70 | } |
||
71 | |||
72 | 1 | $showBar = Arr::get($config, 'showBar', true); |
|
73 | 1 | if ($showBar === true) { |
|
74 | 1 | $kernel->prependMiddleware(RenderBar::class); |
|
75 | } |
||
76 | 1 | } |
|
77 | |||
78 | /** |
||
79 | * Register the service provider. |
||
80 | */ |
||
81 | public function register() |
||
82 | { |
||
83 | $this->mergeConfigFrom(__DIR__.'/../config/tracy.php', 'tracy'); |
||
84 | |||
85 | $config = Arr::get($this->app['config'], 'tracy'); |
||
86 | |||
87 | if (Arr::get($config, 'panels.terminal') === true) { |
||
88 | $this->app->register(TerminalServiceProvider::class); |
||
89 | } |
||
90 | |||
91 | $this->app->singleton(BlueScreen::class, function () { |
||
92 | return Debugger::getBlueScreen(); |
||
93 | }); |
||
94 | |||
95 | $this->app->singleton(Bar::class, function ($app) use ($config) { |
||
96 | return (new BarManager(Debugger::getBar(), $app['request'], $app)) |
||
97 | ->loadPanels(Arr::get($config, 'panels', [])) |
||
98 | ->getBar(); |
||
99 | }); |
||
100 | |||
101 | $this->app->singleton(DebuggerManager::class, function ($app) use ($config) { |
||
102 | return (new DebuggerManager( |
||
103 | DebuggerManager::init($config), |
||
104 | $app[Bar::class], |
||
105 | $app[BlueScreen::class], |
||
106 | new Session |
||
107 | ))->setUrlGenerator($app['url']); |
||
108 | }); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Get the services provided by the provider. |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | 1 | public function provides() |
|
117 | { |
||
118 | 1 | return [ExceptionHandler::class]; |
|
119 | } |
||
120 | |||
121 | /** |
||
122 | * register routes. |
||
123 | * |
||
124 | * @param \Illuminate\Routing\Router $router |
||
125 | * @param array $config |
||
126 | */ |
||
127 | 2 | protected function handleRoutes(Router $router, $config = []) |
|
137 | } |
||
138 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.