@@ -107,7 +107,7 @@ |
||
107 | 107 | if (!empty($pageUrl)) { |
108 | 108 | $query->andWhere(['url' => $pageUrl]); |
109 | 109 | } |
110 | - if ((int)$siteId !== 0) { |
|
110 | + if ((int) $siteId !== 0) { |
|
111 | 111 | $query->andWhere(['siteId' => $siteId]); |
112 | 112 | } |
113 | 113 | $stats = $query->all(); |
@@ -38,10 +38,10 @@ |
||
38 | 38 | $phpMemoryLimit = $this->memoryLimit(); |
39 | 39 | if ($phpMemoryLimit && $this->sample->craftTotalMemory) { |
40 | 40 | $ratio = $phpMemoryLimit / $this->sample->craftTotalMemory; |
41 | - $displayCraftTotalMemory = (($this->sample->craftTotalMemory / 1024) / 1024) . 'M'; |
|
42 | - $displayPhpMemoryLimit = (($phpMemoryLimit / 1024) / 1024) . 'M'; |
|
43 | - $displayCraftMinMemory = ((self::MIN_CRAFT_MEMORY / 1024) / 1024) . 'M'; |
|
44 | - $displayCraftMaxMemory = ((self::MAX_CRAFT_MEMORY / 1024) / 1024) . 'M'; |
|
41 | + $displayCraftTotalMemory = (($this->sample->craftTotalMemory / 1024) / 1024).'M'; |
|
42 | + $displayPhpMemoryLimit = (($phpMemoryLimit / 1024) / 1024).'M'; |
|
43 | + $displayCraftMinMemory = ((self::MIN_CRAFT_MEMORY / 1024) / 1024).'M'; |
|
44 | + $displayCraftMaxMemory = ((self::MAX_CRAFT_MEMORY / 1024) / 1024).'M'; |
|
45 | 45 | $this->summary = Craft::t( |
46 | 46 | 'webperf', |
47 | 47 | 'Check the `memory_limit` setting in your `php.ini` file', |
@@ -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 !== '') { |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | foreach ($stats as $stat) { |
387 | 387 | switch ($stat['type']) { |
388 | 388 | case 'boomerang': |
389 | - $boomerangErrors['data'][] = (int)$stat['cnt']; |
|
389 | + $boomerangErrors['data'][] = (int) $stat['cnt']; |
|
390 | 390 | $boomerangErrors['labels'][] = $stat['sampleDate']; |
391 | 391 | break; |
392 | 392 | case 'craft': |
393 | - $craftErrors['data'][] = (int)$stat['cnt']; |
|
393 | + $craftErrors['data'][] = (int) $stat['cnt']; |
|
394 | 394 | $craftErrors['labels'][] = $stat['sampleDate']; |
395 | 395 | break; |
396 | 396 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | Event::on( |
293 | 293 | Plugins::class, |
294 | 294 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
295 | - function (PluginEvent $event) { |
|
295 | + function(PluginEvent $event) { |
|
296 | 296 | if ($event->plugin === $this) { |
297 | 297 | // Invalidate our caches after we've been installed |
298 | 298 | $this->clearAllCaches(); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | Event::on( |
321 | 321 | CraftVariable::class, |
322 | 322 | CraftVariable::EVENT_INIT, |
323 | - function (Event $event) { |
|
323 | + function(Event $event) { |
|
324 | 324 | /** @var CraftVariable $variable */ |
325 | 325 | $variable = $event->sender; |
326 | 326 | $variable->set('webperf', WebperfVariable::class); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | Event::on( |
331 | 331 | Plugins::class, |
332 | 332 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
333 | - function () { |
|
333 | + function() { |
|
334 | 334 | // Install these only after all other plugins have loaded |
335 | 335 | $request = Craft::$app->getRequest(); |
336 | 336 | // Only respond to non-console site requests |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | Event::on( |
355 | 355 | UrlManager::class, |
356 | 356 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
357 | - function (RegisterUrlRulesEvent $event) { |
|
357 | + function(RegisterUrlRulesEvent $event) { |
|
358 | 358 | Craft::debug( |
359 | 359 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
360 | 360 | __METHOD__ |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | Event::on( |
378 | 378 | UrlManager::class, |
379 | 379 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
380 | - function (RegisterUrlRulesEvent $event) { |
|
380 | + function(RegisterUrlRulesEvent $event) { |
|
381 | 381 | Craft::debug( |
382 | 382 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
383 | 383 | __METHOD__ |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | Event::on( |
394 | 394 | Dashboard::class, |
395 | 395 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
396 | - function (RegisterComponentTypesEvent $event) { |
|
396 | + function(RegisterComponentTypesEvent $event) { |
|
397 | 397 | $event->types[] = MetricsWidget::class; |
398 | 398 | } |
399 | 399 | ); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | Event::on( |
402 | 402 | UserPermissions::class, |
403 | 403 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
404 | - function (RegisterUserPermissionsEvent $event) { |
|
404 | + function(RegisterUserPermissionsEvent $event) { |
|
405 | 405 | Craft::debug( |
406 | 406 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
407 | 407 | __METHOD__ |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | Event::on( |
427 | 427 | View::class, |
428 | 428 | View::EVENT_END_PAGE, |
429 | - function () { |
|
429 | + function() { |
|
430 | 430 | Craft::debug( |
431 | 431 | 'View::EVENT_END_PAGE', |
432 | 432 | __METHOD__ |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | Event::on( |
451 | 451 | View::class, |
452 | 452 | View::EVENT_END_BODY, |
453 | - function () { |
|
453 | + function() { |
|
454 | 454 | Craft::debug( |
455 | 455 | 'View::EVENT_END_BODY', |
456 | 456 | __METHOD__ |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | Event::on( |
474 | 474 | Application::class, |
475 | 475 | Application::EVENT_AFTER_REQUEST, |
476 | - function () { |
|
476 | + function() { |
|
477 | 477 | Craft::debug( |
478 | 478 | 'Application::EVENT_AFTER_REQUEST', |
479 | 479 | __METHOD__ |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | { |
646 | 646 | $cache = Craft::$app->getCache(); |
647 | 647 | // See if there are any recommendations to add as a badge |
648 | - $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () { |
|
648 | + $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() { |
|
649 | 649 | $data = []; |
650 | 650 | $now = new \DateTime(); |
651 | 651 | $end = $now->format('Y-m-d'); |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $recommendations = ''; |
664 | 664 | } |
665 | 665 | |
666 | - return (string)$recommendations; |
|
666 | + return (string) $recommendations; |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | /** |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | { |
676 | 676 | $cache = Craft::$app->getCache(); |
677 | 677 | // See if there are any recommendations to add as a badge |
678 | - $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () { |
|
678 | + $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() { |
|
679 | 679 | $now = new \DateTime(); |
680 | 680 | $end = $now->format('Y-m-d'); |
681 | 681 | $start = $now->modify('-30 days')->format('Y-m-d'); |
@@ -689,6 +689,6 @@ discard block |
||
689 | 689 | $errors = '⚠'; |
690 | 690 | } |
691 | 691 | |
692 | - return (string)$errors; |
|
692 | + return (string) $errors; |
|
693 | 693 | } |
694 | 694 | } |
@@ -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 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ->from(['{{%webperf_error_samples}}']) |
109 | 109 | ->where(['between', 'dateCreated', $start, $end]) |
110 | 110 | ; |
111 | - if ((int)$siteId !== 0) { |
|
111 | + if ((int) $siteId !== 0) { |
|
112 | 112 | $query->andWhere(['siteId' => $siteId]); |
113 | 113 | } |
114 | 114 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ['not', ['title' => '']], |
135 | 135 | ]) |
136 | 136 | ; |
137 | - if ((int)$siteId !== 0) { |
|
137 | + if ((int) $siteId !== 0) { |
|
138 | 138 | $query->andWhere(['siteId' => $siteId]); |
139 | 139 | } |
140 | 140 | $result = $query->one(); |