@@ -144,14 +144,17 @@ public function boot()
144
144
/** @var Application $app */
145
145
$ app = $ this ->app ;
146
146
147
+ /** @var \Illuminate\Config\Repository $config */
148
+ $ config = $ app ['config ' ];
149
+
147
150
/** @var \Illuminate\Events\Dispatcher|null $events */
148
151
$ events = isset ($ app ['events ' ]) ? $ app ['events ' ] : null ;
149
152
150
- $ this ->editorTemplateLink = $ this -> app [ ' config ' ] ->get ('debugbar.editor ' ) ?: null ;
153
+ $ this ->editorTemplateLink = $ config ->get ('debugbar.editor ' ) ?: null ;
151
154
$ this ->remoteServerReplacements = $ this ->getRemoteServerReplacements ();
152
155
153
156
// Set custom error handler
154
- if ($ app [ ' config ' ] ->get ('debugbar.error_handler ' , false )) {
157
+ if ($ config ->get ('debugbar.error_handler ' , false )) {
155
158
set_error_handler ([$ this , 'handleError ' ]);
156
159
}
157
160
@@ -162,25 +165,23 @@ public function boot()
162
165
}
163
166
164
167
if ($ this ->shouldCollect ('messages ' , true )) {
165
- $ trace = $ this ->app ['config ' ]->get ('debugbar.options.messages.trace ' , true );
166
- $ messages = new MessagesCollector ();
167
- if ($ trace ) {
168
- $ messages ->collectFileTrace (true );
169
- }
168
+ $ this ->addCollector (new MessagesCollector ());
170
169
171
- $ this ->addCollector ($ messages );
170
+ if ($ config ->get ('debugbar.options.messages.trace ' , true )) {
171
+ $ this ['messages ' ]->collectFileTrace (true );
172
+ }
172
173
}
173
174
174
175
if ($ this ->shouldCollect ('time ' , true )) {
175
176
$ startTime = $ app ['request ' ]->server ('REQUEST_TIME_FLOAT ' );
176
177
$ this ->addCollector (new TimeDataCollector ($ startTime ));
177
178
178
- if ($ app [ ' config ' ] ->get ('debugbar.options.time.memory_usage ' )) {
179
+ if ($ config ->get ('debugbar.options.time.memory_usage ' )) {
179
180
$ debugbar ['time ' ]->showMemoryUsage ();
180
181
}
181
182
182
183
if (! $ this ->isLumen () && $ startTime ) {
183
- $ this -> app ->booted (
184
+ $ app ->booted (
184
185
function () use ($ debugbar , $ startTime ) {
185
186
$ debugbar ->addMeasure ('Booting ' , $ startTime , microtime (true ), [], 'time ' );
186
187
}
@@ -193,12 +194,12 @@ function () use ($debugbar, $startTime) {
193
194
if ($ this ->shouldCollect ('memory ' , true )) {
194
195
$ memoryCollector = new MemoryCollector ();
195
196
if (method_exists ($ memoryCollector , 'setPrecision ' )) {
196
- $ memoryCollector ->setPrecision ($ app [ ' config ' ] ->get ('debugbar.options.memory.precision ' , 0 ));
197
+ $ memoryCollector ->setPrecision ($ config ->get ('debugbar.options.memory.precision ' , 0 ));
197
198
}
198
- if (function_exists ('memory_reset_peak_usage ' ) && $ app [ ' config ' ] ->get ('debugbar.options.memory.reset_peak ' )) {
199
+ if (function_exists ('memory_reset_peak_usage ' ) && $ config ->get ('debugbar.options.memory.reset_peak ' )) {
199
200
memory_reset_peak_usage ();
200
201
}
201
- if ($ app [ ' config ' ] ->get ('debugbar.options.memory.with_baseline ' )) {
202
+ if ($ config ->get ('debugbar.options.memory.with_baseline ' )) {
202
203
$ memoryCollector ->resetMemoryBaseline ();
203
204
}
204
205
$ this ->addCollector ($ memoryCollector );
@@ -208,15 +209,15 @@ function () use ($debugbar, $startTime) {
208
209
try {
209
210
$ exceptionCollector = new ExceptionsCollector ();
210
211
$ exceptionCollector ->setChainExceptions (
211
- $ this -> app [ ' config ' ] ->get ('debugbar.options.exceptions.chain ' , true )
212
+ $ config ->get ('debugbar.options.exceptions.chain ' , true )
212
213
);
213
214
$ this ->addCollector ($ exceptionCollector );
214
215
} catch (Exception $ e ) {
215
216
}
216
217
}
217
218
218
219
if ($ this ->shouldCollect ('laravel ' , false )) {
219
- $ this ->addCollector (new LaravelCollector ($ this -> app ));
220
+ $ this ->addCollector (new LaravelCollector ($ app ));
220
221
}
221
222
222
223
if ($ this ->shouldCollect ('default_request ' , false )) {
@@ -226,7 +227,7 @@ function () use ($debugbar, $startTime) {
226
227
if ($ this ->shouldCollect ('events ' , false ) && $ events ) {
227
228
try {
228
229
$ startTime = $ app ['request ' ]->server ('REQUEST_TIME_FLOAT ' );
229
- $ collectData = $ app [ ' config ' ] ->get ('debugbar.options.events.data ' , false );
230
+ $ collectData = $ config ->get ('debugbar.options.events.data ' , false );
230
231
$ this ->addCollector (new EventCollector ($ startTime , $ collectData ));
231
232
$ events ->subscribe ($ this ['event ' ]);
232
233
} catch (Exception $ e ) {
@@ -236,9 +237,9 @@ function () use ($debugbar, $startTime) {
236
237
237
238
if ($ this ->shouldCollect ('views ' , true ) && $ events ) {
238
239
try {
239
- $ collectData = $ this -> app [ ' config ' ] ->get ('debugbar.options.views.data ' , true );
240
- $ excludePaths = $ this -> app [ ' config ' ] ->get ('debugbar.options.views.exclude_paths ' , []);
241
- $ group = $ this -> app [ ' config ' ] ->get ('debugbar.options.views.group ' , true );
240
+ $ collectData = $ config ->get ('debugbar.options.views.data ' , true );
241
+ $ excludePaths = $ config ->get ('debugbar.options.views.exclude_paths ' , []);
242
+ $ group = $ config ->get ('debugbar.options.views.group ' , true );
242
243
$ this ->addCollector (new ViewCollector ($ collectData , $ excludePaths , $ group ));
243
244
$ events ->listen (
244
245
'composing:* ' ,
@@ -264,7 +265,7 @@ function ($event, $params) {
264
265
if ($ this ->hasCollector ('messages ' )) {
265
266
$ logger = new MessagesCollector ('log ' );
266
267
$ this ['messages ' ]->aggregate ($ logger );
267
- $ this -> app ['log ' ]->listen (
268
+ $ app ['log ' ]->listen (
268
269
function (\Illuminate \Log \Events \MessageLogged $ log ) use ($ logger ) {
269
270
try {
270
271
$ logMessage = (string ) $ log ->message ;
@@ -292,47 +293,42 @@ function (\Illuminate\Log\Events\MessageLogged $log) use ($logger) {
292
293
}
293
294
}
294
295
295
- if ($ this ->shouldCollect ('db ' , true ) && isset ($ this -> app ['db ' ]) && $ events ) {
296
+ if ($ this ->shouldCollect ('db ' , true ) && isset ($ app ['db ' ]) && $ events ) {
296
297
if (
297
- $ debugbar ->hasCollector ('time ' ) && $ this ->app ['config ' ]->get (
298
- 'debugbar.options.db.timeline ' ,
299
- false
300
- )
301
- ) {
298
+ $ debugbar ->hasCollector ('time ' ) && $ config ->get ('debugbar.options.db.timeline ' , false )) {
302
299
$ timeCollector = $ debugbar ->getCollector ('time ' );
303
300
} else {
304
301
$ timeCollector = null ;
305
302
}
306
303
$ queryCollector = new QueryCollector ($ timeCollector );
307
304
308
305
$ queryCollector ->setDataFormatter (new QueryFormatter ());
309
- $ queryCollector ->setLimits ($ this ->app ['config ' ]->get ('debugbar.options.db.soft_limit ' ), $ this ->app ['config ' ]->get ('debugbar.options.db.hard_limit ' ));
310
- if ($ this ->app ['config ' ]->get ('debugbar.options.db.with_params ' )) {
306
+ $ queryCollector ->setLimits ($ config ->get ('debugbar.options.db.soft_limit ' ), $ config ->get ('debugbar.options.db.hard_limit ' ));
307
+ $ queryCollector ->setDurationBackground ($ config ->get ('debugbar.options.db.duration_background ' ));
308
+
309
+ if ($ config ->get ('debugbar.options.db.with_params ' )) {
311
310
$ queryCollector ->setRenderSqlWithParams (true );
312
311
}
313
312
314
- if ($ this -> app [ ' config ' ] ->get ('debugbar.options.db.backtrace ' )) {
315
- $ middleware = ! $ this ->is_lumen ? $ this -> app ['router ' ]->getMiddleware () : [];
313
+ if ($ config ->get ('debugbar.options.db.backtrace ' )) {
314
+ $ middleware = ! $ this ->is_lumen ? $ app ['router ' ]->getMiddleware () : [];
316
315
$ queryCollector ->setFindSource (true , $ middleware );
317
316
}
318
317
319
- if ($ this ->app ['config ' ]->get ('debugbar.options.db.backtrace_exclude_paths ' )) {
320
- $ excludePaths = $ this ->app ['config ' ]->get ('debugbar.options.db.backtrace_exclude_paths ' );
318
+ if ($ excludePaths = $ config ->get ('debugbar.options.db.backtrace_exclude_paths ' )) {
321
319
$ queryCollector ->mergeBacktraceExcludePaths ($ excludePaths );
322
320
}
323
321
324
- $ queryCollector ->setDurationBackground ($ this ->app ['config ' ]->get ('debugbar.options.db.duration_background ' ));
325
-
326
- if ($ this ->app ['config ' ]->get ('debugbar.options.db.explain.enabled ' )) {
327
- $ types = $ this ->app ['config ' ]->get ('debugbar.options.db.explain.types ' );
322
+ if ($ config ->get ('debugbar.options.db.explain.enabled ' )) {
323
+ $ types = $ config ->get ('debugbar.options.db.explain.types ' );
328
324
$ queryCollector ->setExplainSource (true , $ types );
329
325
}
330
326
331
- if ($ this -> app [ ' config ' ] ->get ('debugbar.options.db.hints ' , true )) {
327
+ if ($ config ->get ('debugbar.options.db.hints ' , true )) {
332
328
$ queryCollector ->setShowHints (true );
333
329
}
334
330
335
- if ($ this -> app [ ' config ' ] ->get ('debugbar.options.db.show_copy ' , false )) {
331
+ if ($ config ->get ('debugbar.options.db.show_copy ' , false )) {
336
332
$ queryCollector ->setShowCopyButton (true );
337
333
}
338
334
@@ -444,13 +440,13 @@ function (\Illuminate\Database\Events\ConnectionEstablished $event) use ($queryC
444
440
$ mailCollector ->addSymfonyMessage ($ event ->sent ->getSymfonySentMessage ());
445
441
});
446
442
447
- if ($ this -> app [ ' config ' ] ->get ('debugbar.options.mail.full_log ' )) {
443
+ if ($ config ->get ('debugbar.options.mail.full_log ' )) {
448
444
$ mailCollector ->showMessageDetail ();
449
445
}
450
446
451
- if ($ debugbar ->hasCollector ('time ' ) && $ this -> app [ ' config ' ] ->get ('debugbar.options.mail.timeline ' )) {
452
- $ transport = $ this -> app ['mailer ' ]->getSymfonyTransport ();
453
- $ this -> app ['mailer ' ]->setSymfonyTransport (new class ($ transport , $ this ) extends AbstractTransport{
447
+ if ($ debugbar ->hasCollector ('time ' ) && $ config ->get ('debugbar.options.mail.timeline ' )) {
448
+ $ transport = $ app ['mailer ' ]->getSymfonyTransport ();
449
+ $ app ['mailer ' ]->setSymfonyTransport (new class ($ transport , $ this ) extends AbstractTransport{
454
450
private $ originalTransport ;
455
451
private $ laravelDebugbar ;
456
452
@@ -485,7 +481,7 @@ public function __toString(): string
485
481
486
482
if ($ this ->shouldCollect ('logs ' , false )) {
487
483
try {
488
- $ file = $ this -> app [ ' config ' ] ->get ('debugbar.options.logs.file ' );
484
+ $ file = $ config ->get ('debugbar.options.logs.file ' );
489
485
$ this ->addCollector (new LogsCollector ($ file ));
490
486
} catch (Exception $ e ) {
491
487
$ this ->addCollectorException ('Cannot add LogsCollector ' , $ e );
@@ -497,11 +493,11 @@ public function __toString(): string
497
493
498
494
if ($ this ->shouldCollect ('auth ' , false )) {
499
495
try {
500
- $ guards = $ this -> app [ ' config ' ] ->get ('auth.guards ' , []);
496
+ $ guards = $ config ->get ('auth.guards ' , []);
501
497
$ authCollector = new MultiAuthCollector ($ app ['auth ' ], $ guards );
502
498
503
499
$ authCollector ->setShowName (
504
- $ this -> app [ ' config ' ] ->get ('debugbar.options.auth.show_name ' )
500
+ $ config ->get ('debugbar.options.auth.show_name ' )
505
501
);
506
502
$ this ->addCollector ($ authCollector );
507
503
} catch (Exception $ e ) {
@@ -519,8 +515,8 @@ public function __toString(): string
519
515
520
516
if ($ this ->shouldCollect ('cache ' , false ) && $ events ) {
521
517
try {
522
- $ collectValues = $ this -> app [ ' config ' ] ->get ('debugbar.options.cache.values ' , true );
523
- $ startTime = $ this -> app ['request ' ]->server ('REQUEST_TIME_FLOAT ' );
518
+ $ collectValues = $ config ->get ('debugbar.options.cache.values ' , true );
519
+ $ startTime = $ app ['request ' ]->server ('REQUEST_TIME_FLOAT ' );
524
520
$ cacheCollector = new CacheCollector ($ startTime , $ collectValues );
525
521
$ this ->addCollector ($ cacheCollector );
526
522
$ events ->subscribe ($ cacheCollector );
@@ -541,9 +537,9 @@ public function __toString(): string
541
537
}
542
538
543
539
$ renderer = $ this ->getJavascriptRenderer ();
544
- $ renderer ->setIncludeVendors ($ this -> app [ ' config ' ] ->get ('debugbar.include_vendors ' , true ));
545
- $ renderer ->setBindAjaxHandlerToFetch ($ app [ ' config ' ] ->get ('debugbar.capture_ajax ' , true ));
546
- $ renderer ->setBindAjaxHandlerToXHR ($ app [ ' config ' ] ->get ('debugbar.capture_ajax ' , true ));
540
+ $ renderer ->setIncludeVendors ($ config ->get ('debugbar.include_vendors ' , true ));
541
+ $ renderer ->setBindAjaxHandlerToFetch ($ config ->get ('debugbar.capture_ajax ' , true ));
542
+ $ renderer ->setBindAjaxHandlerToXHR ($ config ->get ('debugbar.capture_ajax ' , true ));
547
543
548
544
$ this ->booted = true ;
549
545
}
@@ -697,6 +693,7 @@ public function getJavascriptRenderer($baseUrl = null, $basePath = null)
697
693
*/
698
694
public function modifyResponse (Request $ request , Response $ response )
699
695
{
696
+ /** @var Application $app */
700
697
$ app = $ this ->app ;
701
698
if (!$ this ->isEnabled () || $ this ->isDebugbarRequest ()) {
702
699
return $ response ;
@@ -718,7 +715,7 @@ public function modifyResponse(Request $request, Response $response)
718
715
}
719
716
720
717
$ sessionHiddens = $ app ['config ' ]->get ('debugbar.options.session.hiddens ' , []);
721
- if ($ this -> app ->bound (SessionManager::class)) {
718
+ if ($ app ->bound (SessionManager::class)) {
722
719
723
720
/** @var \Illuminate\Session\SessionManager $sessionManager */
724
721
$ sessionManager = $ app ->make (SessionManager::class);
@@ -812,6 +809,7 @@ public function modifyResponse(Request $request, Response $response)
812
809
public function isEnabled ()
813
810
{
814
811
if ($ this ->enabled === null ) {
812
+ /** @var \Illuminate\Config\Repository $config */
815
813
$ config = $ this ->app ['config ' ];
816
814
$ configEnabled = value ($ config ->get ('debugbar.enabled ' ));
817
815
@@ -901,6 +899,7 @@ function (&$item) {
901
899
*/
902
900
public function injectDebugbar (Response $ response )
903
901
{
902
+ /** @var \Illuminate\Config\Repository $config */
904
903
$ config = $ this ->app ['config ' ];
905
904
$ content = $ response ->getContent ();
906
905
@@ -1092,6 +1091,7 @@ protected function isLumen()
1092
1091
*/
1093
1092
protected function selectStorage (DebugBar $ debugbar )
1094
1093
{
1094
+ /** @var \Illuminate\Config\Repository $config */
1095
1095
$ config = $ this ->app ['config ' ];
1096
1096
if ($ config ->get ('debugbar.storage.enabled ' )) {
1097
1097
$ driver = $ config ->get ('debugbar.storage.driver ' , 'file ' );
0 commit comments