@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | // Constants aren't allowed in traits until PHP >= 8.2 |
40 | 40 | $majorVersion = '3'; |
41 | 41 | // Dev server container name & port are based on the major version of this plugin |
42 | - $devPort = 3000 + (int)$majorVersion; |
|
43 | - $versionName = 'v' . $majorVersion; |
|
42 | + $devPort = 3000 + (int) $majorVersion; |
|
43 | + $versionName = 'v'.$majorVersion; |
|
44 | 44 | // Merge in the passed config, so it our config can be overridden by Plugins::pluginConfigs['retour'] |
45 | 45 | // ref: https://github.com/craftcms/cms/issues/1989 |
46 | 46 | $config = ArrayHelper::merge([ |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | 'assetClass' => RetourAsset::class, |
54 | 54 | 'checkDevServer' => true, |
55 | 55 | 'class' => VitePluginService::class, |
56 | - 'devServerInternal' => 'http://craft-retour-' . $versionName . '-buildchain-dev:' . $devPort, |
|
57 | - 'devServerPublic' => 'http://localhost:' . $devPort, |
|
56 | + 'devServerInternal' => 'http://craft-retour-'.$versionName.'-buildchain-dev:'.$devPort, |
|
57 | + 'devServerPublic' => 'http://localhost:'.$devPort, |
|
58 | 58 | 'errorEntry' => 'src/js/Retour.js', |
59 | 59 | 'useDevServer' => true, |
60 | 60 | ], |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | ->addBooleanField($field) |
65 | 65 | ->resolve(function($redirect) use ($field) { |
66 | 66 | $result = $redirect[$field] ?? null; |
67 | - return $result === null ? $result : (bool)$result; |
|
67 | + return $result === null ? $result : (bool) $result; |
|
68 | 68 | }); |
69 | 69 | } elseif (in_array($field, self::INT_FIELDS, true)) { |
70 | 70 | // Integer field |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ->addIntField($field) |
73 | 73 | ->resolve(function($redirect) use ($field) { |
74 | 74 | $result = $redirect[$field] ?? null; |
75 | - return $result === null ? $result : (int)$result; |
|
75 | + return $result === null ? $result : (int) $result; |
|
76 | 76 | }); |
77 | 77 | } else { |
78 | 78 | // String field |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | ->addStringField($field) |
81 | 81 | ->resolve(function($redirect) use ($field) { |
82 | 82 | $result = $redirect[$field] ?? null; |
83 | - return $result === null ? $result : (string)$result; |
|
83 | + return $result === null ? $result : (string) $result; |
|
84 | 84 | }); |
85 | 85 | } |
86 | 86 | } |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([ |
49 | 49 | 'name' => static::getName(), |
50 | - 'fields' => self::class . '::getFieldDefinitions', |
|
50 | + 'fields' => self::class.'::getFieldDefinitions', |
|
51 | 51 | 'description' => 'This is the interface implemented by Retour.', |
52 | 52 | 'resolveType' => function(array $value) { |
53 | 53 | return GqlEntityRegistry::getEntity(RetourGenerator::getName()); |
@@ -41,14 +41,14 @@ discard block |
||
41 | 41 | 'retour' => [ |
42 | 42 | 'type' => RetourInterface::getType(), |
43 | 43 | 'args' => RetourArguments::getArguments(), |
44 | - 'resolve' => RetourResolver::class . '::resolve', |
|
44 | + 'resolve' => RetourResolver::class.'::resolve', |
|
45 | 45 | 'description' => 'This query is used to query for Retour redirects.', |
46 | 46 | 'deprecationReason' => 'This query is deprecated and will be removed in the future. You should use `retourResolveRedirect` instead.', |
47 | 47 | ], |
48 | 48 | 'retourResolveRedirect' => [ |
49 | 49 | 'type' => RetourInterface::getType(), |
50 | 50 | 'args' => RetourArguments::getArguments(), |
51 | - 'resolve' => RetourResolver::class . '::resolve', |
|
51 | + 'resolve' => RetourResolver::class.'::resolve', |
|
52 | 52 | 'description' => 'This query is used to query for Retour redirects.', |
53 | 53 | ], |
54 | 54 | 'retourRedirects' => [ |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'description' => 'The siteId to list all redirects for.', |
66 | 66 | ], |
67 | 67 | ], |
68 | - 'resolve' => RetourResolver::class . '::resolveAll', |
|
68 | + 'resolve' => RetourResolver::class.'::resolveAll', |
|
69 | 69 | 'description' => 'This query is used to query for all Retour redirects for a site.', |
70 | 70 | ], |
71 | 71 | ]; |
@@ -65,8 +65,8 @@ |
||
65 | 65 | // Set the `site` virtual field |
66 | 66 | $redirect['site'] = null; |
67 | 67 | $redirect['siteId'] = $siteId; |
68 | - if (isset($redirect['siteId']) && (int)$redirect['siteId'] !== 0) { |
|
69 | - $site = Craft::$app->getSites()->getSiteById((int)$redirect['siteId']); |
|
68 | + if (isset($redirect['siteId']) && (int) $redirect['siteId'] !== 0) { |
|
69 | + $site = Craft::$app->getSites()->getSiteById((int) $redirect['siteId']); |
|
70 | 70 | if ($site !== null) { |
71 | 71 | $redirect['site'] = $site->handle; |
72 | 72 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
203 | 203 | $variables['pluginName'] = $pluginName; |
204 | 204 | $variables['title'] = $templateTitle; |
205 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
205 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
206 | 206 | $variables['crumbs'] = [ |
207 | 207 | [ |
208 | 208 | 'label' => $pluginName, |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | ], |
211 | 211 | [ |
212 | 212 | 'label' => 'Redirects', |
213 | - 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
213 | + 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
214 | 214 | ], |
215 | 215 | ]; |
216 | 216 | $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $file = UploadedFile::getInstanceByName('file'); |
221 | 221 | if ($file !== null) { |
222 | 222 | $filename = uniqid($file->name, true); |
223 | - $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; |
|
223 | + $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename; |
|
224 | 224 | $file->saveAs($filePath, false); |
225 | 225 | // Also save the file to the cache as a backup way to access it |
226 | 226 | $fileContents = @file_get_contents($filePath); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | $csv->insertOne(array_values($columns)); |
355 | 355 | $csv->insertAll($data); |
356 | - $csv->output($filename . '.csv'); |
|
356 | + $csv->output($filename.'.csv'); |
|
357 | 357 | exit(0); |
358 | 358 | } |
359 | 359 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $columns = ArrayHelper::filterEmptyStringsFromArray($columns); |
372 | 372 | $rowIndex = 1; |
373 | 373 | /** @phpstan-ignore-next-line */ |
374 | - $csv->each(function ($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
374 | + $csv->each(function($row) use ($headers, $columns, &$rowIndex, &$hasErrors) { |
|
375 | 375 | $redirectConfig = [ |
376 | 376 | 'id' => 0, |
377 | 377 | ]; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | $index++; |
386 | 386 | } |
387 | 387 | $redirectDump = print_r($redirectConfig, true); |
388 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
388 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
389 | 389 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
390 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
390 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
391 | 391 | $hasErrors = true; |
392 | 392 | } |
393 | 393 | $rowIndex++; |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | $index++; |
428 | 428 | } |
429 | 429 | $redirectDump = print_r($redirectConfig, true); |
430 | - Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
430 | + Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
431 | 431 | if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) { |
432 | - Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__); |
|
432 | + Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__); |
|
433 | 433 | $hasErrors = true; |
434 | 434 | } |
435 | 435 | $rowIndex++; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $siteId = reset($variables['enabledSiteIds']); |
88 | 88 | } |
89 | 89 | } else { |
90 | - self::requirePermission('editSite:' . $siteId); |
|
90 | + self::requirePermission('editSite:'.$siteId); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } else { |
113 | 113 | $variables['sitesMenuLabel'] = Craft::t( |
114 | 114 | 'site', |
115 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
115 | + $sites->getSiteById((int) $variables['currentSiteId'])->name |
|
116 | 116 | ); |
117 | 117 | } |
118 | 118 | } else { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | if ($siteHandle !== null) { |
137 | 137 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
138 | 138 | if (!$site) { |
139 | - throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
139 | + throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
140 | 140 | } |
141 | 141 | $siteId = $site->id; |
142 | 142 | } |
@@ -5,7 +5,7 @@ |
||
5 | 5 | |
6 | 6 | return static function(ECSConfig $ecsConfig): void { |
7 | 7 | $ecsConfig->paths([ |
8 | - __DIR__ . '/src', |
|
8 | + __DIR__.'/src', |
|
9 | 9 | __FILE__, |
10 | 10 | ]); |
11 | 11 | $ecsConfig->parallel(); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public function getRecentStatistics($days = 1, $handled = false): array |
78 | 78 | { |
79 | 79 | // Ensure is an int |
80 | - $handledInt = (int)$handled; |
|
80 | + $handledInt = (int) $handled; |
|
81 | 81 | $stats = []; |
82 | 82 | $db = Craft::$app->getDb(); |
83 | 83 | if ($db->getIsMysql()) { |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | $stats->userAgent = $userAgent; |
213 | 213 | $stats->exceptionMessage = $exceptionMessage; |
214 | 214 | $stats->exceptionFilePath = $exceptionFilePath; |
215 | - $stats->exceptionFileLine = (int)$exceptionFileLine; |
|
215 | + $stats->exceptionFileLine = (int) $exceptionFileLine; |
|
216 | 216 | $stats->hitLastTime = Db::prepareDateForDb(new DateTime()); |
217 | - $stats->handledByRetour = (int)$handled; |
|
217 | + $stats->handledByRetour = (int) $handled; |
|
218 | 218 | $stats->hitCount++; |
219 | 219 | $statsConfig = $stats->getAttributes(); |
220 | 220 | // Record the updated statistics |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | $now = round(microtime(true) * 1000); |
359 | 359 | $cache = Craft::$app->getCache(); |
360 | 360 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); |
361 | - if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { |
|
361 | + if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { |
|
362 | 362 | $limited = true; |
363 | 363 | } |
364 | 364 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); |