@@ -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 !== '') { |
@@ -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 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | Event::on( |
302 | 302 | Plugins::class, |
303 | 303 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
304 | - function (PluginEvent $event) { |
|
304 | + function(PluginEvent $event) { |
|
305 | 305 | if ($event->plugin === $this) { |
306 | 306 | // Invalidate our caches after we've been installed |
307 | 307 | $this->clearAllCaches(); |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | Event::on( |
330 | 330 | CraftVariable::class, |
331 | 331 | CraftVariable::EVENT_INIT, |
332 | - function (Event $event) { |
|
332 | + function(Event $event) { |
|
333 | 333 | /** @var CraftVariable $variable */ |
334 | 334 | $variable = $event->sender; |
335 | 335 | $variable->set('webperf', WebperfVariable::class); |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | Event::on( |
340 | 340 | Plugins::class, |
341 | 341 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
342 | - function () { |
|
342 | + function() { |
|
343 | 343 | // Install these only after all other plugins have loaded |
344 | 344 | $request = Craft::$app->getRequest(); |
345 | 345 | // Only respond to non-console site requests |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | Event::on( |
364 | 364 | UrlManager::class, |
365 | 365 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
366 | - function (RegisterUrlRulesEvent $event) { |
|
366 | + function(RegisterUrlRulesEvent $event) { |
|
367 | 367 | Craft::debug( |
368 | 368 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
369 | 369 | __METHOD__ |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | Event::on( |
387 | 387 | UrlManager::class, |
388 | 388 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
389 | - function (RegisterUrlRulesEvent $event) { |
|
389 | + function(RegisterUrlRulesEvent $event) { |
|
390 | 390 | Craft::debug( |
391 | 391 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
392 | 392 | __METHOD__ |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | Event::on( |
403 | 403 | Dashboard::class, |
404 | 404 | Dashboard::EVENT_REGISTER_WIDGET_TYPES, |
405 | - function (RegisterComponentTypesEvent $event) { |
|
405 | + function(RegisterComponentTypesEvent $event) { |
|
406 | 406 | $event->types[] = MetricsWidget::class; |
407 | 407 | } |
408 | 408 | ); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | Event::on( |
411 | 411 | UserPermissions::class, |
412 | 412 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
413 | - function (RegisterUserPermissionsEvent $event) { |
|
413 | + function(RegisterUserPermissionsEvent $event) { |
|
414 | 414 | Craft::debug( |
415 | 415 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
416 | 416 | __METHOD__ |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | Event::on( |
436 | 436 | View::class, |
437 | 437 | View::EVENT_END_PAGE, |
438 | - function () { |
|
438 | + function() { |
|
439 | 439 | Craft::debug( |
440 | 440 | 'View::EVENT_END_PAGE', |
441 | 441 | __METHOD__ |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | Event::on( |
460 | 460 | View::class, |
461 | 461 | View::EVENT_END_BODY, |
462 | - function () { |
|
462 | + function() { |
|
463 | 463 | Craft::debug( |
464 | 464 | 'View::EVENT_END_BODY', |
465 | 465 | __METHOD__ |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | Event::on( |
483 | 483 | Application::class, |
484 | 484 | Application::EVENT_AFTER_REQUEST, |
485 | - function () { |
|
485 | + function() { |
|
486 | 486 | Craft::debug( |
487 | 487 | 'Application::EVENT_AFTER_REQUEST', |
488 | 488 | __METHOD__ |
@@ -508,21 +508,21 @@ discard block |
||
508 | 508 | if (self::$settings->displaySidebar && $currentUser->can('webperf:sidebar')) { |
509 | 509 | $view = Craft::$app->getView(); |
510 | 510 | // Entries sidebar |
511 | - $view->hook('cp.entries.edit.details', function (&$context) { |
|
511 | + $view->hook('cp.entries.edit.details', function(&$context) { |
|
512 | 512 | /** @var Element $element */ |
513 | 513 | $element = $context['entry'] ?? null; |
514 | 514 | |
515 | 515 | return $this->renderSidebar($element); |
516 | 516 | }); |
517 | 517 | // Category Groups sidebar |
518 | - $view->hook('cp.categories.edit.details', function (&$context) { |
|
518 | + $view->hook('cp.categories.edit.details', function(&$context) { |
|
519 | 519 | /** @var Element $element */ |
520 | 520 | $element = $context['category'] ?? null; |
521 | 521 | |
522 | 522 | return $this->renderSidebar($element); |
523 | 523 | }); |
524 | 524 | // Commerce Product Types sidebar |
525 | - $view->hook('cp.commerce.product.edit.details', function (&$context) { |
|
525 | + $view->hook('cp.commerce.product.edit.details', function(&$context) { |
|
526 | 526 | /** @var Element $element */ |
527 | 527 | $element = $context['product'] ?? null; |
528 | 528 | |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | { |
730 | 730 | $cache = Craft::$app->getCache(); |
731 | 731 | // See if there are any recommendations to add as a badge |
732 | - $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function () { |
|
732 | + $recommendations = $cache->getOrSet(self::RECOMMENDATIONS_CACHE_KEY, function() { |
|
733 | 733 | $data = []; |
734 | 734 | $now = new \DateTime(); |
735 | 735 | $end = $now->format('Y-m-d'); |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | $recommendations = ''; |
748 | 748 | } |
749 | 749 | |
750 | - return (string)$recommendations; |
|
750 | + return (string) $recommendations; |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | { |
760 | 760 | $cache = Craft::$app->getCache(); |
761 | 761 | // See if there are any recommendations to add as a badge |
762 | - $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function () { |
|
762 | + $errors = $cache->getOrSet(self::ERRORS_CACHE_KEY, function() { |
|
763 | 763 | $now = new \DateTime(); |
764 | 764 | $end = $now->format('Y-m-d'); |
765 | 765 | $start = $now->modify('-30 days')->format('Y-m-d'); |
@@ -773,6 +773,6 @@ discard block |
||
773 | 773 | $errors = '⚠'; |
774 | 774 | } |
775 | 775 | |
776 | - return (string)$errors; |
|
776 | + return (string) $errors; |
|
777 | 777 | } |
778 | 778 | } |
@@ -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 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ->andWhere(['type' => $type]) |
115 | 115 | ; |
116 | 116 | } |
117 | - if ((int)$siteId !== 0) { |
|
117 | + if ((int) $siteId !== 0) { |
|
118 | 118 | $query->andWhere(['siteId' => $siteId]); |
119 | 119 | } |
120 | 120 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ['not', ['title' => '']], |
141 | 141 | ]) |
142 | 142 | ; |
143 | - if ((int)$siteId !== 0) { |
|
143 | + if ((int) $siteId !== 0) { |
|
144 | 144 | $query->andWhere(['siteId' => $siteId]); |
145 | 145 | } |
146 | 146 | $result = $query->one(); |