@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ->from(['{{%webperf_data_samples}}']) |
49 | 49 | ->where(['not', [$column => null]]) |
50 | 50 | ; |
51 | - if ((int)$siteId !== 0) { |
|
51 | + if ((int) $siteId !== 0) { |
|
52 | 52 | $query->andWhere(['siteId' => $siteId]); |
53 | 53 | } |
54 | 54 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | ['not', ['title' => '']], |
75 | 75 | ]) |
76 | 76 | ; |
77 | - if ((int)$siteId !== 0) { |
|
77 | + if ((int) $siteId !== 0) { |
|
78 | 78 | $query->andWhere(['siteId' => $siteId]); |
79 | 79 | } |
80 | 80 | $result = $query->one(); |
@@ -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 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | ->from(['{{%webperf_error_samples}}']) |
83 | 83 | ->where(['not', [$column => null]]) |
84 | 84 | ; |
85 | - if ((int)$siteId !== 0) { |
|
85 | + if ((int) $siteId !== 0) { |
|
86 | 86 | $query->andWhere(['siteId' => $siteId]); |
87 | 87 | } |
88 | 88 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ->andWhere(['url' => $pageUrl]) |
121 | 121 | ; |
122 | 122 | } |
123 | - if ((int)$siteId !== 0) { |
|
123 | + if ((int) $siteId !== 0) { |
|
124 | 124 | $query->andWhere(['siteId' => $siteId]); |
125 | 125 | } |
126 | 126 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | ['not', ['title' => '']], |
147 | 147 | ]) |
148 | 148 | ; |
149 | - if ((int)$siteId !== 0) { |
|
149 | + if ((int) $siteId !== 0) { |
|
150 | 150 | $query->andWhere(['siteId' => $siteId]); |
151 | 151 | } |
152 | 152 | $result = $query->one(); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | Event::on( |
316 | 316 | Plugins::class, |
317 | 317 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
318 | - function (PluginEvent $event) { |
|
318 | + function(PluginEvent $event) { |
|
319 | 319 | if ($event->plugin === $this) { |
320 | 320 | // Invalidate our caches after we've been installed |
321 | 321 | $this->clearAllCaches(); |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | Event::on( |
344 | 344 | CraftVariable::class, |
345 | 345 | CraftVariable::EVENT_INIT, |
346 | - function (Event $event) { |
|
346 | + function(Event $event) { |
|
347 | 347 | /** @var CraftVariable $variable */ |
348 | 348 | $variable = $event->sender; |
349 | 349 | $variable->set('webperf', WebperfVariable::class); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | Event::on( |
354 | 354 | Plugins::class, |
355 | 355 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
356 | - function () { |
|
356 | + function() { |
|
357 | 357 | // Install these only after all other plugins have loaded |
358 | 358 | $request = Craft::$app->getRequest(); |
359 | 359 | // Only respond to non-console site requests |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | Event::on( |
378 | 378 | UrlManager::class, |
379 | 379 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
380 | - function (RegisterUrlRulesEvent $event) { |
|
380 | + function(RegisterUrlRulesEvent $event) { |
|
381 | 381 | Craft::debug( |
382 | 382 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
383 | 383 | __METHOD__ |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | Event::on( |
401 | 401 | UrlManager::class, |
402 | 402 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
403 | - function (RegisterUrlRulesEvent $event) { |
|
403 | + function(RegisterUrlRulesEvent $event) { |
|
404 | 404 | Craft::debug( |
405 | 405 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
406 | 406 | __METHOD__ |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | Event::on( |
417 | 417 | UserPermissions::class, |
418 | 418 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
419 | - function (RegisterUserPermissionsEvent $event) { |
|
419 | + function(RegisterUserPermissionsEvent $event) { |
|
420 | 420 | Craft::debug( |
421 | 421 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
422 | 422 | __METHOD__ |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | Event::on( |
447 | 447 | View::class, |
448 | 448 | View::EVENT_END_PAGE, |
449 | - function () { |
|
449 | + function() { |
|
450 | 450 | Craft::debug( |
451 | 451 | 'View::EVENT_END_PAGE', |
452 | 452 | __METHOD__ |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | Event::on( |
475 | 475 | View::class, |
476 | 476 | View::EVENT_END_BODY, |
477 | - function () { |
|
477 | + function() { |
|
478 | 478 | Craft::debug( |
479 | 479 | 'View::EVENT_END_BODY', |
480 | 480 | __METHOD__ |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | Event::on( |
498 | 498 | Application::class, |
499 | 499 | Application::EVENT_AFTER_REQUEST, |
500 | - function () { |
|
500 | + function() { |
|
501 | 501 | Craft::debug( |
502 | 502 | 'Application::EVENT_AFTER_REQUEST', |
503 | 503 | __METHOD__ |
@@ -523,21 +523,21 @@ discard block |
||
523 | 523 | if (self::$settings->displaySidebar && $currentUser && $currentUser->can('webperf:sidebar')) { |
524 | 524 | $view = Craft::$app->getView(); |
525 | 525 | // Entries sidebar |
526 | - $view->hook('cp.entries.edit.details', function (&$context) { |
|
526 | + $view->hook('cp.entries.edit.details', function(&$context) { |
|
527 | 527 | /** @var Element $element */ |
528 | 528 | $element = $context['entry'] ?? null; |
529 | 529 | |
530 | 530 | return $this->renderSidebar($element); |
531 | 531 | }); |
532 | 532 | // Category Groups sidebar |
533 | - $view->hook('cp.categories.edit.details', function (&$context) { |
|
533 | + $view->hook('cp.categories.edit.details', function(&$context) { |
|
534 | 534 | /** @var Element $element */ |
535 | 535 | $element = $context['category'] ?? null; |
536 | 536 | |
537 | 537 | return $this->renderSidebar($element); |
538 | 538 | }); |
539 | 539 | // Commerce Product Types sidebar |
540 | - $view->hook('cp.commerce.product.edit.details', function (&$context) { |
|
540 | + $view->hook('cp.commerce.product.edit.details', function(&$context) { |
|
541 | 541 | /** @var Element $element */ |
542 | 542 | $element = $context['product'] ?? null; |
543 | 543 | |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | { |
756 | 756 | $cache = Craft::$app->getCache(); |
757 | 757 | // See if there are any recommendations to add as a badge |
758 | - $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () { |
|
758 | + $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() { |
|
759 | 759 | $data = []; |
760 | 760 | $now = new \DateTime(); |
761 | 761 | $end = $now->format('Y-m-d'); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $recommendations = ''; |
774 | 774 | } |
775 | 775 | |
776 | - return (string)$recommendations; |
|
776 | + return (string) $recommendations; |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | { |
786 | 786 | $cache = Craft::$app->getCache(); |
787 | 787 | // See if there are any recommendations to add as a badge |
788 | - $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () { |
|
788 | + $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() { |
|
789 | 789 | $now = new \DateTime(); |
790 | 790 | $end = $now->format('Y-m-d'); |
791 | 791 | $start = $now->modify('-30 days')->format('Y-m-d'); |
@@ -799,6 +799,6 @@ discard block |
||
799 | 799 | $errors = '⚠'; |
800 | 800 | } |
801 | 801 | |
802 | - return (string)$errors; |
|
802 | + return (string) $errors; |
|
803 | 803 | } |
804 | 804 | } |
@@ -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 | } |
@@ -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 | Craft::warning('Beacon ignored due to rate limiting', __METHOD__); |
207 | 207 | } |