@@ -45,6 +45,6 @@ |
||
45 | 45 | */ |
46 | 46 | public function displayMs(int $number): string |
47 | 47 | { |
48 | - return number_format((float)$number / 1000, 2).'s'; |
|
48 | + return number_format((float) $number / 1000, 2).'s'; |
|
49 | 49 | } |
50 | 50 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | ]) |
82 | 82 | ->where(['between', 'dateCreated', $start, $end]) |
83 | 83 | ->andWhere(['not', [$column => null]]); |
84 | - if ((int)$siteId !== 0) { |
|
84 | + if ((int) $siteId !== 0) { |
|
85 | 85 | $query->andWhere(['siteId' => $siteId]); |
86 | 86 | } |
87 | 87 | if ($pageUrl !== '') { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // Massage the data |
92 | 92 | if ($stats) { |
93 | 93 | foreach ($stats as &$stat) { |
94 | - $stat['cnt'] = (int)$stat['cnt']; |
|
94 | + $stat['cnt'] = (int) $stat['cnt']; |
|
95 | 95 | } |
96 | 96 | $data = $stats[0]; |
97 | 97 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ]) |
137 | 137 | ->where(['between', 'dateCreated', $start, $end]) |
138 | 138 | ->andWhere(['not', [$column => null]]); |
139 | - if ((int)$siteId !== 0) { |
|
139 | + if ((int) $siteId !== 0) { |
|
140 | 140 | $query->andWhere(['siteId' => $siteId]); |
141 | 141 | } |
142 | 142 | $query |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | // Massage the data |
148 | 148 | if ($stats) { |
149 | 149 | foreach ($stats as &$stat) { |
150 | - $stat['cnt'] = (int)$stat['cnt']; |
|
150 | + $stat['cnt'] = (int) $stat['cnt']; |
|
151 | 151 | $stat['detailPageUrl'] = UrlHelper::cpUrl('webperf/performance/page-detail', [ |
152 | 152 | 'pageUrl' => $stat['url'], |
153 | 153 | 'siteId' => $siteId, |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | ]) |
219 | 219 | ->where(['between', 'dateCreated', $start, $end]) |
220 | 220 | ; |
221 | - if ((int)$siteId !== 0) { |
|
221 | + if ((int) $siteId !== 0) { |
|
222 | 222 | $query->andWhere(['siteId' => $siteId]); |
223 | 223 | } |
224 | 224 | if ($pageUrl !== '') { |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | ]) |
348 | 348 | ->where(['between', 'dateCreated', $start, $end]) |
349 | 349 | ; |
350 | - if ((int)$siteId !== 0) { |
|
350 | + if ((int) $siteId !== 0) { |
|
351 | 351 | $query->andWhere(['siteId' => $siteId]); |
352 | 352 | } |
353 | 353 | if ($pageUrl !== '') { |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | $craftErrors['labels'][$index] = $stat['sampleDate']; |
392 | 392 | switch ($stat['type']) { |
393 | 393 | case 'boomerang': |
394 | - $boomerangErrors['data'][$index] = (int)$stat['cnt']; |
|
394 | + $boomerangErrors['data'][$index] = (int) $stat['cnt']; |
|
395 | 395 | $boomerangErrors['labels'][$index] = $stat['sampleDate']; |
396 | 396 | break; |
397 | 397 | case 'craft': |
398 | - $craftErrors['data'][$index] = (int)$stat['cnt']; |
|
398 | + $craftErrors['data'][$index] = (int) $stat['cnt']; |
|
399 | 399 | $craftErrors['labels'][$index] = $stat['sampleDate']; |
400 | 400 | break; |
401 | 401 | } |
@@ -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); |