@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ->offset($offset) |
| 105 | 105 | ->where(['between', 'dateCreated', $start, $end]) |
| 106 | 106 | ; |
| 107 | - if ((int)$siteId !== 0) { |
|
| 107 | + if ((int) $siteId !== 0) { |
|
| 108 | 108 | $query->andWhere(['siteId' => $siteId]); |
| 109 | 109 | } |
| 110 | 110 | if ($filter !== '') { |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | $index = 1; |
| 144 | 144 | foreach ($stats as &$stat) { |
| 145 | 145 | $stat['id'] = $index++; |
| 146 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 147 | - $stat['maxTotalPageLoad'] = (int)$maxTotalPageLoad; |
|
| 146 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 147 | + $stat['maxTotalPageLoad'] = (int) $maxTotalPageLoad; |
|
| 148 | 148 | // Decode any emojis in the title |
| 149 | 149 | if (!empty($stat['title'])) { |
| 150 | 150 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | ->where(['url' => $pageUrl]) |
| 243 | 243 | ->andWhere(['between', 'dateCreated', $start, $end]) |
| 244 | 244 | ; |
| 245 | - if ((int)$siteId !== 0) { |
|
| 245 | + if ((int) $siteId !== 0) { |
|
| 246 | 246 | $query->andWhere(['siteId' => $siteId]); |
| 247 | 247 | } |
| 248 | 248 | if ($filter !== '') { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $stat['type'] = 'frontend'; |
| 275 | 275 | } |
| 276 | 276 | if ($stat['pageLoad'] > $maxTotalPageLoad) { |
| 277 | - $maxTotalPageLoad = (int)$stat['pageLoad']; |
|
| 277 | + $maxTotalPageLoad = (int) $stat['pageLoad']; |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | // Massage the stats |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | $date = DateTimeHelper::toDateTime($stats['dateCreated']); |
| 284 | 284 | $stats['dateCreated'] = $date->format('Y-m-d H:i:s'); |
| 285 | 285 | } |
| 286 | - $stat['mobile'] = (bool)$stat['mobile']; |
|
| 287 | - $stat['maxTotalPageLoad'] = (int)$maxTotalPageLoad; |
|
| 286 | + $stat['mobile'] = (bool) $stat['mobile']; |
|
| 287 | + $stat['maxTotalPageLoad'] = (int) $maxTotalPageLoad; |
|
| 288 | 288 | // Decode any emojis in the title |
| 289 | 289 | if (!empty($stat['title'])) { |
| 290 | 290 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | 'SUM(case when [[type]] = \'boomerang\' then 1 else 0 end) as [[boomerangCount]]', |
| 397 | 397 | ]); |
| 398 | 398 | } |
| 399 | - if ((int)$siteId !== 0) { |
|
| 399 | + if ((int) $siteId !== 0) { |
|
| 400 | 400 | $query->andWhere(['siteId' => $siteId]); |
| 401 | 401 | } |
| 402 | 402 | if ($filter !== '') { |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | $user = Craft::$app->getUser()->getIdentity(); |
| 418 | 418 | // Massage the stats |
| 419 | 419 | foreach ($stats as &$stat) { |
| 420 | - $stat['cnt'] = (int)$stat['cnt']; |
|
| 421 | - $stat['craftCount'] = (int)$stat['craftCount']; |
|
| 422 | - $stat['boomerangCount'] = (int)$stat['boomerangCount']; |
|
| 420 | + $stat['cnt'] = (int) $stat['cnt']; |
|
| 421 | + $stat['craftCount'] = (int) $stat['craftCount']; |
|
| 422 | + $stat['boomerangCount'] = (int) $stat['boomerangCount']; |
|
| 423 | 423 | // Decode any emojis in the title |
| 424 | 424 | if (!empty($stat['title'])) { |
| 425 | 425 | $stat['title'] = html_entity_decode($stat['title'], ENT_NOQUOTES, 'UTF-8'); |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | ->andWhere(['between', '[[webperf_error_samples.dateCreated]]', $start, $end]) |
| 537 | 537 | ->leftJoin('{{%webperf_data_samples}} webperf_data_samples', '[[webperf_data_samples.requestId]] = [[webperf_error_samples.requestId]]') |
| 538 | 538 | ; |
| 539 | - if ((int)$siteId !== 0) { |
|
| 539 | + if ((int) $siteId !== 0) { |
|
| 540 | 540 | $query->andWhere(['siteId' => $siteId]); |
| 541 | 541 | } |
| 542 | 542 | if ($filter !== '') { |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | $stats['dateCreated'] = $date->format('Y-m-d H:i:s'); |
| 565 | 565 | } |
| 566 | 566 | if (isset($stat['mobile'])) { |
| 567 | - $stat['mobile'] = (bool)$stat['mobile']; |
|
| 567 | + $stat['mobile'] = (bool) $stat['mobile']; |
|
| 568 | 568 | } |
| 569 | 569 | // Decode any emojis in the title |
| 570 | 570 | if (!empty($stat['title'])) { |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function evaluate() |
| 37 | 37 | { |
| 38 | - $phpMemoryLimit = (int)$this->memoryLimit(); |
|
| 39 | - $this->sample->craftTotalMemory = (int)$this->sample->craftTotalMemory; |
|
| 38 | + $phpMemoryLimit = (int) $this->memoryLimit(); |
|
| 39 | + $this->sample->craftTotalMemory = (int) $this->sample->craftTotalMemory; |
|
| 40 | 40 | if ($phpMemoryLimit && $this->sample->craftTotalMemory) { |
| 41 | 41 | $ratio = $phpMemoryLimit / $this->sample->craftTotalMemory; |
| 42 | - $displayCraftTotalMemory = (($this->sample->craftTotalMemory / 1024) / 1024) . 'M'; |
|
| 43 | - $displayPhpMemoryLimit = (($phpMemoryLimit / 1024) / 1024) . 'M'; |
|
| 44 | - $displayCraftMinMemory = ((self::MIN_CRAFT_MEMORY / 1024) / 1024) . 'M'; |
|
| 45 | - $displayCraftMaxMemory = ((self::MAX_CRAFT_MEMORY / 1024) / 1024) . 'M'; |
|
| 42 | + $displayCraftTotalMemory = (($this->sample->craftTotalMemory / 1024) / 1024).'M'; |
|
| 43 | + $displayPhpMemoryLimit = (($phpMemoryLimit / 1024) / 1024).'M'; |
|
| 44 | + $displayCraftMinMemory = ((self::MIN_CRAFT_MEMORY / 1024) / 1024).'M'; |
|
| 45 | + $displayCraftMaxMemory = ((self::MAX_CRAFT_MEMORY / 1024) / 1024).'M'; |
|
| 46 | 46 | $this->summary = Craft::t( |
| 47 | 47 | 'webperf', |
| 48 | 48 | 'Check the `memory_limit` setting in your `php.ini` file', |
@@ -114,6 +114,6 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - return (int)$memoryLimit; |
|
| 117 | + return (int) $memoryLimit; |
|
| 118 | 118 | } |
| 119 | 119 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | Event::on( |
| 324 | 324 | Plugins::class, |
| 325 | 325 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 326 | - function (PluginEvent $event) { |
|
| 326 | + function(PluginEvent $event) { |
|
| 327 | 327 | if ($event->plugin === $this) { |
| 328 | 328 | // Invalidate our caches after we've been installed |
| 329 | 329 | $this->clearAllCaches(); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | Event::on( |
| 352 | 352 | CraftVariable::class, |
| 353 | 353 | CraftVariable::EVENT_INIT, |
| 354 | - function (Event $event) { |
|
| 354 | + function(Event $event) { |
|
| 355 | 355 | /** @var CraftVariable $variable */ |
| 356 | 356 | $variable = $event->sender; |
| 357 | 357 | $variable->set('webperf', WebperfVariable::class); |
@@ -361,11 +361,11 @@ discard block |
||
| 361 | 361 | Event::on( |
| 362 | 362 | Plugins::class, |
| 363 | 363 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 364 | - function () { |
|
| 364 | + function() { |
|
| 365 | 365 | // Install these only after all other plugins have loaded |
| 366 | 366 | $request = Craft::$app->getRequest(); |
| 367 | 367 | // Only respond to non-console site requests |
| 368 | - if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest() && !$request->getIsLivePreview()) { |
|
| 368 | + if ($request->getIsSiteRequest() && !$request->getIsConsoleRequest() && !$request->getIsLivePreview()) { |
|
| 369 | 369 | $this->handleSiteRequest(); |
| 370 | 370 | } |
| 371 | 371 | // Respond to Control Panel requests |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | Event::on( |
| 386 | 386 | UrlManager::class, |
| 387 | 387 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 388 | - function (RegisterUrlRulesEvent $event) { |
|
| 388 | + function(RegisterUrlRulesEvent $event) { |
|
| 389 | 389 | Craft::debug( |
| 390 | 390 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 391 | 391 | __METHOD__ |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | Event::on( |
| 409 | 409 | UrlManager::class, |
| 410 | 410 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 411 | - function (RegisterUrlRulesEvent $event) { |
|
| 411 | + function(RegisterUrlRulesEvent $event) { |
|
| 412 | 412 | Craft::debug( |
| 413 | 413 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 414 | 414 | __METHOD__ |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | Event::on( |
| 425 | 425 | UserPermissions::class, |
| 426 | 426 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 427 | - function (RegisterUserPermissionsEvent $event) { |
|
| 427 | + function(RegisterUserPermissionsEvent $event) { |
|
| 428 | 428 | Craft::debug( |
| 429 | 429 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 430 | 430 | __METHOD__ |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | Event::on( |
| 455 | 455 | View::class, |
| 456 | 456 | View::EVENT_END_PAGE, |
| 457 | - function () { |
|
| 457 | + function() { |
|
| 458 | 458 | Craft::debug( |
| 459 | 459 | 'View::EVENT_END_PAGE', |
| 460 | 460 | __METHOD__ |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | Event::on( |
| 483 | 483 | View::class, |
| 484 | 484 | View::EVENT_END_BODY, |
| 485 | - function () { |
|
| 485 | + function() { |
|
| 486 | 486 | Craft::debug( |
| 487 | 487 | 'View::EVENT_END_BODY', |
| 488 | 488 | __METHOD__ |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | Event::on( |
| 506 | 506 | Application::class, |
| 507 | 507 | Application::EVENT_AFTER_REQUEST, |
| 508 | - function () { |
|
| 508 | + function() { |
|
| 509 | 509 | Craft::debug( |
| 510 | 510 | 'Application::EVENT_AFTER_REQUEST', |
| 511 | 511 | __METHOD__ |
@@ -531,21 +531,21 @@ discard block |
||
| 531 | 531 | if (self::$settings->displaySidebar && $currentUser && $currentUser->can('webperf:sidebar')) { |
| 532 | 532 | $view = Craft::$app->getView(); |
| 533 | 533 | // Entries sidebar |
| 534 | - $view->hook('cp.entries.edit.details', function (&$context) { |
|
| 534 | + $view->hook('cp.entries.edit.details', function(&$context) { |
|
| 535 | 535 | /** @var Element $element */ |
| 536 | 536 | $element = $context['entry'] ?? null; |
| 537 | 537 | |
| 538 | 538 | return $this->renderSidebar($element); |
| 539 | 539 | }); |
| 540 | 540 | // Category Groups sidebar |
| 541 | - $view->hook('cp.categories.edit.details', function (&$context) { |
|
| 541 | + $view->hook('cp.categories.edit.details', function(&$context) { |
|
| 542 | 542 | /** @var Element $element */ |
| 543 | 543 | $element = $context['category'] ?? null; |
| 544 | 544 | |
| 545 | 545 | return $this->renderSidebar($element); |
| 546 | 546 | }); |
| 547 | 547 | // Commerce Product Types sidebar |
| 548 | - $view->hook('cp.commerce.product.edit.details', function (&$context) { |
|
| 548 | + $view->hook('cp.commerce.product.edit.details', function(&$context) { |
|
| 549 | 549 | /** @var Element $element */ |
| 550 | 550 | $element = $context['product'] ?? null; |
| 551 | 551 | |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | { |
| 766 | 766 | $cache = Craft::$app->getCache(); |
| 767 | 767 | // See if there are any recommendations to add as a badge |
| 768 | - $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () { |
|
| 768 | + $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() { |
|
| 769 | 769 | $data = []; |
| 770 | 770 | $now = new \DateTime(); |
| 771 | 771 | $end = $now->format('Y-m-d'); |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | $recommendations = ''; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | - return (string)$recommendations; |
|
| 786 | + return (string) $recommendations; |
|
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /** |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | { |
| 796 | 796 | $cache = Craft::$app->getCache(); |
| 797 | 797 | // See if there are any recommendations to add as a badge |
| 798 | - $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () { |
|
| 798 | + $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() { |
|
| 799 | 799 | $now = new \DateTime(); |
| 800 | 800 | $end = $now->format('Y-m-d'); |
| 801 | 801 | $start = $now->modify('-30 days')->format('Y-m-d'); |
@@ -809,6 +809,6 @@ discard block |
||
| 809 | 809 | $errors = '⚠'; |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - return (string)$errors; |
|
| 812 | + return (string) $errors; |
|
| 813 | 813 | } |
| 814 | 814 | } |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | if ($userAgent) { |
| 164 | 164 | $parser = new Parser($userAgent); |
| 165 | 165 | $sample->device = ($parser->device->model ?? ''); |
| 166 | - $sample->browser = ($parser->browser->name ?? '') . ' ' . $parser->browser->getVersion(); |
|
| 167 | - $sample->os = ($parser->os->name ?? '') . ' ' . $parser->os->getVersion(); |
|
| 166 | + $sample->browser = ($parser->browser->name ?? '').' '.$parser->browser->getVersion(); |
|
| 167 | + $sample->os = ($parser->os->name ?? '').' '.$parser->os->getVersion(); |
|
| 168 | 168 | $sample->mobile = $parser->isMobile(); |
| 169 | 169 | } |
| 170 | 170 | // Save the data sample |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | $now = round(microtime(true) * 1000); |
| 202 | 202 | $cache = Craft::$app->getCache(); |
| 203 | 203 | $then = $cache->get(self::LAST_BEACON_CACHE_KEY); |
| 204 | - if (($then !== false) && ($now - (int)$then < Webperf::$settings->rateLimitMs)) { |
|
| 204 | + if (($then !== false) && ($now - (int) $then < Webperf::$settings->rateLimitMs)) { |
|
| 205 | 205 | $limited = true; |
| 206 | 206 | } |
| 207 | 207 | $cache->set(self::LAST_BEACON_CACHE_KEY, $now, 0); |
@@ -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(); |
@@ -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); |