@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ->from(['{{%webperf_error_samples}}']) |
| 85 | 85 | ->where(['not', [$column => null]]) |
| 86 | 86 | ; |
| 87 | - if ((int)$siteId !== 0) { |
|
| 87 | + if ((int) $siteId !== 0) { |
|
| 88 | 88 | $query->andWhere(['siteId' => $siteId]); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | ->andWhere(['url' => $pageUrl]) |
| 123 | 123 | ; |
| 124 | 124 | } |
| 125 | - if ((int)$siteId !== 0) { |
|
| 125 | + if ((int) $siteId !== 0) { |
|
| 126 | 126 | $query->andWhere(['siteId' => $siteId]); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | ['not', ['title' => '']], |
| 149 | 149 | ]) |
| 150 | 150 | ; |
| 151 | - if ((int)$siteId !== 0) { |
|
| 151 | + if ((int) $siteId !== 0) { |
|
| 152 | 152 | $query->andWhere(['siteId' => $siteId]); |
| 153 | 153 | } |
| 154 | 154 | $result = $query->one(); |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | $now = round(microtime(true) * 1000); |
| 382 | 382 | $cache = Craft::$app->getCache(); |
| 383 | 383 | $then = $cache->get(self::LAST_ERRORSAMPLES_TRIM_CACHE_KEY); |
| 384 | - if (($then !== false) && ($now - (int)$then < Webperf::$settings->samplesRateLimitMs)) { |
|
| 384 | + if (($then !== false) && ($now - (int) $then < Webperf::$settings->samplesRateLimitMs)) { |
|
| 385 | 385 | $limited = true; |
| 386 | 386 | } |
| 387 | 387 | $cache->set(self::LAST_ERRORSAMPLES_TRIM_CACHE_KEY, $now, 0); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | ->from(['{{%webperf_data_samples}}']) |
| 87 | 87 | ->where(['not', [$column => null]]) |
| 88 | 88 | ; |
| 89 | - if ((int)$siteId !== 0) { |
|
| 89 | + if ((int) $siteId !== 0) { |
|
| 90 | 90 | $query->andWhere(['siteId' => $siteId]); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | ['not', ['title' => '']], |
| 113 | 113 | ]) |
| 114 | 114 | ; |
| 115 | - if ((int)$siteId !== 0) { |
|
| 115 | + if ((int) $siteId !== 0) { |
|
| 116 | 116 | $query->andWhere(['siteId' => $siteId]); |
| 117 | 117 | } |
| 118 | 118 | $result = $query->one(); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | ->from('{{%webperf_data_samples}}') |
| 303 | 303 | ->average('[[pageLoad]]'); |
| 304 | 304 | if (!empty($stats)) { |
| 305 | - $threshold = (int)($stats * self::OUTLIER_PAGELOAD_MULTIPLIER); |
|
| 305 | + $threshold = (int) ($stats * self::OUTLIER_PAGELOAD_MULTIPLIER); |
|
| 306 | 306 | // Delete any samples that are far above average |
| 307 | 307 | try { |
| 308 | 308 | $result = $db->createCommand()->delete( |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | $now = round(microtime(true) * 1000); |
| 426 | 426 | $cache = Craft::$app->getCache(); |
| 427 | 427 | $then = $cache->get(self::LAST_DATASAMPLES_TRIM_CACHE_KEY); |
| 428 | - if (($then !== false) && ($now - (int)$then < Webperf::$settings->samplesRateLimitMs)) { |
|
| 428 | + if (($then !== false) && ($now - (int) $then < Webperf::$settings->samplesRateLimitMs)) { |
|
| 429 | 429 | $limited = true; |
| 430 | 430 | } |
| 431 | 431 | $cache->set(self::LAST_DATASAMPLES_TRIM_CACHE_KEY, $now, 0); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } else { |
| 113 | 113 | $variables['sitesMenuLabel'] = Craft::t( |
| 114 | 114 | 'site', |
| 115 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
| 115 | + $sites->getSiteById((int) $variables['currentSiteId'])->name |
|
| 116 | 116 | ); |
| 117 | 117 | } |
| 118 | 118 | } else { |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | if (($parsed = parse_url(self::getBaseUrl($site))) === false) { |
| 175 | - Craft::warning('Unable to parse the site base URL: ' . $site->baseUrl); |
|
| 175 | + Craft::warning('Unable to parse the site base URL: '.$site->baseUrl); |
|
| 176 | 176 | continue; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | // Does the site URL specify a base path? |
| 185 | 185 | $parsedPath = !empty($parsed['path']) ? self::normalizePath($parsed['path']) : ''; |
| 186 | - if ($parsedPath && strpos($fullUri . '/', $parsedPath . '/') !== 0) { |
|
| 186 | + if ($parsedPath && strpos($fullUri.'/', $parsedPath.'/') !== 0) { |
|
| 187 | 187 | continue; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | protected static function getBaseUrl(Site $site) |
| 258 | 258 | { |
| 259 | 259 | if ($site->baseUrl) { |
| 260 | - return rtrim(self::parseEnv($site->baseUrl), '/') . '/'; |
|
| 260 | + return rtrim(self::parseEnv($site->baseUrl), '/').'/'; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | return null; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | Event::on( |
| 362 | 362 | Plugins::class, |
| 363 | 363 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 364 | - function (PluginEvent $event) { |
|
| 364 | + function(PluginEvent $event) { |
|
| 365 | 365 | if ($event->plugin === $this) { |
| 366 | 366 | // Invalidate our caches after we've been installed |
| 367 | 367 | $this->clearAllCaches(); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | Event::on( |
| 390 | 390 | CraftVariable::class, |
| 391 | 391 | CraftVariable::EVENT_INIT, |
| 392 | - function (Event $event) { |
|
| 392 | + function(Event $event) { |
|
| 393 | 393 | /** @var CraftVariable $variable */ |
| 394 | 394 | $variable = $event->sender; |
| 395 | 395 | $variable->set('webperf', [ |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | Event::on( |
| 403 | 403 | Plugins::class, |
| 404 | 404 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 405 | - function () { |
|
| 405 | + function() { |
|
| 406 | 406 | // Install these only after all other plugins have loaded |
| 407 | 407 | $request = Craft::$app->getRequest(); |
| 408 | 408 | // Only respond to non-console site requests |
| 409 | - if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest() && !$request->getIsLivePreview()) { |
|
| 409 | + if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest() && !$request->getIsLivePreview()) { |
|
| 410 | 410 | $this->handleSiteRequest(); |
| 411 | 411 | } |
| 412 | 412 | // Respond to Control Panel requests |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | Event::on( |
| 427 | 427 | UrlManager::class, |
| 428 | 428 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 429 | - function (RegisterUrlRulesEvent $event) { |
|
| 429 | + function(RegisterUrlRulesEvent $event) { |
|
| 430 | 430 | Craft::debug( |
| 431 | 431 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 432 | 432 | __METHOD__ |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | Event::on( |
| 450 | 450 | UrlManager::class, |
| 451 | 451 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 452 | - function (RegisterUrlRulesEvent $event) { |
|
| 452 | + function(RegisterUrlRulesEvent $event) { |
|
| 453 | 453 | Craft::debug( |
| 454 | 454 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 455 | 455 | __METHOD__ |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | Event::on( |
| 466 | 466 | UserPermissions::class, |
| 467 | 467 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 468 | - function (RegisterUserPermissionsEvent $event) { |
|
| 468 | + function(RegisterUserPermissionsEvent $event) { |
|
| 469 | 469 | Craft::debug( |
| 470 | 470 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 471 | 471 | __METHOD__ |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | Event::on( |
| 496 | 496 | View::class, |
| 497 | 497 | View::EVENT_END_PAGE, |
| 498 | - function () { |
|
| 498 | + function() { |
|
| 499 | 499 | Craft::debug( |
| 500 | 500 | 'View::EVENT_END_PAGE', |
| 501 | 501 | __METHOD__ |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | Event::on( |
| 524 | 524 | View::class, |
| 525 | 525 | View::EVENT_END_BODY, |
| 526 | - function () { |
|
| 526 | + function() { |
|
| 527 | 527 | Craft::debug( |
| 528 | 528 | 'View::EVENT_END_BODY', |
| 529 | 529 | __METHOD__ |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | Event::on( |
| 547 | 547 | Application::class, |
| 548 | 548 | Application::EVENT_AFTER_REQUEST, |
| 549 | - function () { |
|
| 549 | + function() { |
|
| 550 | 550 | Craft::debug( |
| 551 | 551 | 'Application::EVENT_AFTER_REQUEST', |
| 552 | 552 | __METHOD__ |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | if (self::$settings->displaySidebar && $currentUser && $currentUser->can('webperf:sidebar')) { |
| 573 | 573 | $view = Craft::$app->getView(); |
| 574 | 574 | // Entries sidebar |
| 575 | - $view->hook('cp.entries.edit.details', function (&$context) { |
|
| 575 | + $view->hook('cp.entries.edit.details', function(&$context) { |
|
| 576 | 576 | /** @var Element $element */ |
| 577 | 577 | $element = $context['entry'] ?? null; |
| 578 | 578 | $html = ''; |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | return $html; |
| 584 | 584 | }); |
| 585 | 585 | // Category Groups sidebar |
| 586 | - $view->hook('cp.categories.edit.details', function (&$context) { |
|
| 586 | + $view->hook('cp.categories.edit.details', function(&$context) { |
|
| 587 | 587 | /** @var Element $element */ |
| 588 | 588 | $element = $context['category'] ?? null; |
| 589 | 589 | $html = ''; |
@@ -594,7 +594,7 @@ discard block |
||
| 594 | 594 | return $html; |
| 595 | 595 | }); |
| 596 | 596 | // Commerce Product Types sidebar |
| 597 | - $view->hook('cp.commerce.product.edit.details', function (&$context) { |
|
| 597 | + $view->hook('cp.commerce.product.edit.details', function(&$context) { |
|
| 598 | 598 | /** @var Element $element */ |
| 599 | 599 | $element = $context['product'] ?? null; |
| 600 | 600 | $html = ''; |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | { |
| 789 | 789 | $cache = Craft::$app->getCache(); |
| 790 | 790 | // See if there are any recommendations to add as a badge |
| 791 | - $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () { |
|
| 791 | + $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() { |
|
| 792 | 792 | $data = []; |
| 793 | 793 | $now = new \DateTime(); |
| 794 | 794 | $end = $now->format('Y-m-d'); |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | $recommendations = ''; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - return (string)$recommendations; |
|
| 809 | + return (string) $recommendations; |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | /** |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | { |
| 819 | 819 | $cache = Craft::$app->getCache(); |
| 820 | 820 | // See if there are any recommendations to add as a badge |
| 821 | - $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () { |
|
| 821 | + $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() { |
|
| 822 | 822 | $now = new \DateTime(); |
| 823 | 823 | $end = $now->format('Y-m-d'); |
| 824 | 824 | $start = $now->modify('-30 days')->format('Y-m-d'); |
@@ -832,6 +832,6 @@ discard block |
||
| 832 | 832 | $errors = '⚠'; |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - return (string)$errors; |
|
| 835 | + return (string) $errors; |
|
| 836 | 836 | } |
| 837 | 837 | } |