1414use DebugBar \DebugBar ;
1515use DebugBar \OpenHandler ;
1616use Joomla \Application \ApplicationEvents ;
17+ use Joomla \Application \Event \ApplicationEvent ;
1718use Joomla \CMS \Application \CMSApplicationInterface ;
1819use Joomla \CMS \Document \HtmlDocument ;
20+ use Joomla \CMS \Event \Application \AfterRespondEvent ;
21+ use Joomla \CMS \Event \Application \BeforeCompileHeadEvent ;
22+ use Joomla \CMS \Event \Application \BeforeRespondEvent ;
1923use Joomla \CMS \Event \Plugin \AjaxEvent ;
2024use Joomla \CMS \Log \Log ;
2125use Joomla \CMS \Log \LogEntry ;
@@ -172,14 +176,16 @@ public function __construct(DispatcherInterface $dispatcher, array $config, CMSA
172176 $ this ->setApplication ($ app );
173177 $ this ->setDatabase ($ db );
174178
175- $ this ->debugLang = $ this ->getApplication ()->get ('debug_lang ' );
179+ $ app = $ this ->getApplication ();
180+
181+ $ this ->debugLang = $ app ->get ('debug_lang ' );
176182
177183 // Skip the plugin if debug is off
178- if (!$ this ->debugLang && !$ this -> getApplication () ->get ('debug ' )) {
184+ if (!$ this ->debugLang && !$ app ->get ('debug ' )) {
179185 return ;
180186 }
181187
182- $ this -> getApplication () ->set ('gzip ' , false );
188+ $ app ->set ('gzip ' , false );
183189 ob_start ();
184190 ob_implicit_flush (false );
185191
@@ -195,19 +201,19 @@ public function __construct(DispatcherInterface $dispatcher, array $config, CMSA
195201
196202 // Check whether we want to track the request history for future use.
197203 if ($ this ->params ->get ('track_request_history ' , false )) {
198- $ storagePath = JPATH_CACHE . '/plg_system_debug_ ' . $ this -> getApplication () ->getName ();
204+ $ storagePath = JPATH_CACHE . '/plg_system_debug_ ' . $ app ->getName ();
199205 $ this ->debugBar ->setStorage (new FileStorage ($ storagePath ));
200206 }
201207
202- $ this ->debugBar ->setHttpDriver (new JoomlaHttpDriver ($ this -> getApplication () ));
208+ $ this ->debugBar ->setHttpDriver (new JoomlaHttpDriver ($ app ));
203209
204- $ this ->isAjax = $ this -> getApplication () ->getInput ()->get ('option ' ) === 'com_ajax '
205- && $ this -> getApplication ()-> getInput ()->get ('plugin ' ) === 'debug ' && $ this -> getApplication () ->getInput ()->get ('group ' ) === 'system ' ;
210+ $ this ->isAjax = $ app ->getInput ()->get ('option ' ) === 'com_ajax '
211+ && $ app -> getInput ()->get ('plugin ' ) === 'debug ' && $ app ->getInput ()->get ('group ' ) === 'system ' ;
206212
207213 $ this ->showLogs = (bool ) $ this ->params ->get ('logs ' , true );
208214
209215 // Log deprecated class aliases
210- if ($ this ->showLogs && $ this -> getApplication () ->get ('log_deprecated ' )) {
216+ if ($ this ->showLogs && $ app ->get ('log_deprecated ' )) {
211217 foreach (\JLoader::getDeprecatedAliases () as $ deprecation ) {
212218 Log::add (
213219 \sprintf (
@@ -226,11 +232,13 @@ public function __construct(DispatcherInterface $dispatcher, array $config, CMSA
226232 /**
227233 * Add an assets for debugger.
228234 *
235+ * @param BeforeCompileHeadEvent $event The event instance.
236+ *
229237 * @return void
230238 *
231239 * @since 4.0.0
232240 */
233- public function onBeforeCompileHead ()
241+ public function onBeforeCompileHead (BeforeCompileHeadEvent $ event ): void
234242 {
235243 // Only if debugging or language debug is enabled.
236244 if ((JDEBUG || $ this ->debugLang ) && $ this ->isAuthorisedDisplayDebug () && $ this ->getApplication ()->getDocument () instanceof HtmlDocument) {
@@ -261,11 +269,13 @@ public function onBeforeCompileHead()
261269 /**
262270 * Show the debug info.
263271 *
272+ * @param AfterRespondEvent|ApplicationEvent $event The event instance.
273+ *
264274 * @return void
265275 *
266276 * @since 1.6
267277 */
268- public function onAfterRespond ()
278+ public function onAfterRespond (AfterRespondEvent | ApplicationEvent $ event ): void
269279 {
270280 $ endTime = microtime (true ) - $ this ->timeInOnAfterDisconnect ;
271281 $ endMemory = memory_get_peak_usage (false );
@@ -371,7 +381,7 @@ public function onAfterRespond()
371381 /**
372382 * AJAX handler
373383 *
374- * @param AjaxEvent $event
384+ * @param AjaxEvent $event The event instance.
375385 *
376386 * @return void
377387 *
@@ -413,22 +423,20 @@ private function isAuthorisedDisplayDebug(): bool
413423 return $ result ;
414424 }
415425
426+ $ result = true ;
427+
416428 // If the user is not allowed to view the output then end here.
417429 $ filterGroups = (array ) $ this ->params ->get ('filter_groups ' , []);
418430
419431 if (!empty ($ filterGroups )) {
420- $ userGroups = $ this ->getApplication ()->getIdentity ()->get ( ' groups ' ) ;
432+ $ userGroups = $ this ->getApplication ()->getIdentity ()->groups ;
421433
422434 if (!array_intersect ($ filterGroups , $ userGroups )) {
423435 $ result = false ;
424-
425- return false ;
426436 }
427437 }
428438
429- $ result = true ;
430-
431- return true ;
439+ return $ result ;
432440 }
433441
434442 /**
@@ -440,7 +448,7 @@ private function isAuthorisedDisplayDebug(): bool
440448 *
441449 * @since 4.0.0
442450 */
443- public function onAfterDisconnect (ConnectionEvent $ event )
451+ public function onAfterDisconnect (ConnectionEvent $ event ): void
444452 {
445453 if (!JDEBUG ) {
446454 return ;
@@ -657,11 +665,13 @@ private function collectLogs()
657665 /**
658666 * Add server timing headers when profile is activated.
659667 *
668+ * @param BeforeRespondEvent $event The event instance.
669+ *
660670 * @return void
661671 *
662672 * @since 4.1.0
663673 */
664- public function onBeforeRespond (): void
674+ public function onBeforeRespond (BeforeRespondEvent $ event ): void
665675 {
666676 if (!JDEBUG || !$ this ->params ->get ('profile ' , 1 )) {
667677 return ;
0 commit comments