Passed
Push — v3 ( e153f6...4a04ce )
by Andrew
14:32 queued 14s
created
src/gql/interfaces/RetourInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
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());
Please login to merge, or discard this patch.
src/gql/queries/RetourQuery.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         ];
Please login to merge, or discard this patch.
src/gql/resolvers/RetourResolver.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@
 block discarded – undo
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
                     }
Please login to merge, or discard this patch.
src/helpers/MultiSite.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
ecs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/services/Statistics.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/services/Redirects.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                 try {
283 283
                     $siteId = $redirect['siteId'] ?? null;
284 284
                     if ($siteId !== null) {
285
-                        $siteId = (int)$siteId;
285
+                        $siteId = (int) $siteId;
286 286
                     }
287 287
                     $dest = UrlHelper::siteUrl($dest, null, null, $siteId);
288 288
                 } catch (\yii\base\Exception $e) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                     // That's ok
298 298
                 }
299 299
                 if (!empty($queryString)) {
300
-                    $dest = strtok($dest, '?') . '?' . $queryString;
300
+                    $dest = strtok($dest, '?').'?'.$queryString;
301 301
                 }
302 302
             }
303 303
             $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
     public function getRedirectFromCache($url, ?int $siteId = 0)
413 413
     {
414 414
         $cache = Craft::$app->getCache();
415
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
415
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
416 416
         $redirect = $cache->get($cacheKey);
417 417
         Craft::info(
418 418
             Craft::t(
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
         } catch (SiteNotFoundException $e) {
441 441
             $siteId = 1;
442 442
         }
443
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
443
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
444 444
         // Create the dependency tags
445 445
         $dependency = new TagDependency([
446 446
             'tags' => [
447 447
                 $this::GLOBAL_REDIRECTS_CACHE_TAG,
448
-                $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,
448
+                $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,
449 449
             ],
450 450
         ]);
451 451
         $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
         foreach ($redirects as $redirect) {
486 486
             // Figure out what type of source matching to do
487 487
             $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
488
-            $redirectEnabled = (bool)$redirect['enabled'];
488
+            $redirectEnabled = (bool) $redirect['enabled'];
489 489
             if ($redirectEnabled === true) {
490 490
                 switch ($redirectSrcMatch) {
491 491
                     case 'pathonly':
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
 
527 527
                     // Do a regex match
528 528
                     case 'regexmatch':
529
-                        $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i';
529
+                        $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';
530 530
                         try {
531 531
                             if (preg_match($matchRegEx, $url) === 1) {
532 532
                                 $this->incrementRedirectHitCount($redirect);
533 533
                                 // If we're not associated with an EntryID, handle capture group replacement
534
-                                if ((int)$redirect['associatedElementId'] === 0) {
534
+                                if ((int) $redirect['associatedElementId'] === 0) {
535 535
                                     $redirect['redirectDestUrl'] = preg_replace(
536 536
                                         $matchRegEx,
537 537
                                         $redirect['redirectDestUrl'],
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
                             }
560 560
                         } catch (\Exception $e) {
561 561
                             // That's fine
562
-                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__);
562
+                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__);
563 563
                         }
564 564
 
565 565
                         break;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
         foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) {
668 668
             /** @var Plugin $plugin */
669 669
             if (method_exists($plugin, 'retourMatch')) {
670
-                $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match');
670
+                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match');
671 671
             }
672 672
         }
673 673
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
         $db = Craft::$app->getDb();
909 909
         // Trigger a 'beforeDeleteRedirect' event
910 910
         $redirectConfig = $this->getRedirectById($id);
911
-        $isNew = (int)$redirectConfig['id'] === 0;
911
+        $isNew = (int) $redirectConfig['id'] === 0;
912 912
         $event = new RedirectEvent([
913 913
             'isNew' => $isNew,
914 914
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
                         'id' => $redirectConfig['id'],
970 970
                     ]
971 971
                 )->execute();
972
-                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__);
972
+                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__);
973 973
             } catch (\Exception $e) {
974 974
                 Craft::error($e->getMessage(), __METHOD__);
975 975
             }
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
         // Get the validated model attributes and save them to the db
1082 1082
         $redirectConfig = $redirect->getAttributes();
1083 1083
         // 0 for a siteId needs to be converted to null
1084
-        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) {
1084
+        if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) {
1085 1085
             $redirectConfig['siteId'] = null;
1086 1086
         }
1087 1087
         // Throw an event to before saving the redirect
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
         }
1092 1092
 
1093 1093
         // See if a redirect exists with this source URL already
1094
-        if ((int)$redirectConfig['id'] === 0) {
1094
+        if ((int) $redirectConfig['id'] === 0) {
1095 1095
             // Query the db table
1096 1096
             $redirect = (new Query())
1097 1097
                 ->from(['{{%retour_static_redirects}}'])
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
             }
1105 1105
         }
1106 1106
         // Trigger a 'beforeSaveRedirect' event
1107
-        $isNew = (int)$redirectConfig['id'] === 0;
1107
+        $isNew = (int) $redirectConfig['id'] === 0;
1108 1108
         $event = new RedirectEvent([
1109 1109
             'isNew' => $isNew,
1110 1110
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
@@ -1207,13 +1207,13 @@  discard block
 block discarded – undo
1207 1207
      */
1208 1208
     public function excludeUri($uri): bool
1209 1209
     {
1210
-        $uri = '/' . ltrim($uri, '/');
1210
+        $uri = '/'.ltrim($uri, '/');
1211 1211
         if (!empty(Retour::$settings->excludePatterns)) {
1212 1212
             foreach (Retour::$settings->excludePatterns as $excludePattern) {
1213 1213
                 if (empty($excludePattern['pattern'])) {
1214 1214
                     continue;
1215 1215
                 }
1216
-                $pattern = '`' . $excludePattern['pattern'] . '`i';
1216
+                $pattern = '`'.$excludePattern['pattern'].'`i';
1217 1217
                 try {
1218 1218
                     if (preg_match($pattern, $uri) === 1) {
1219 1219
                         Craft::info(
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
                     }
1230 1230
                 } catch (\Exception $e) {
1231 1231
                     // That's fine
1232
-                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__);
1232
+                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__);
1233 1233
                 }
1234 1234
             }
1235 1235
         }
Please login to merge, or discard this patch.
src/controllers/TablesController.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
         string $sort = 'hitCount|desc',
94 94
         int    $page = 1,
95 95
         int    $per_page = 20,
96
-               $filter = '',
97
-               $siteId = 0,
98
-               $handled = 'all'
96
+                $filter = '',
97
+                $siteId = 0,
98
+                $handled = 'all'
99 99
     ): Response {
100 100
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
101 101
         $data = [];
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
         string $sort = 'hitCount|desc',
198 198
         int    $page = 1,
199 199
         int    $per_page = 20,
200
-               $filter = '',
201
-               $siteId = 0,
202
-               $shortLinks = false
200
+                $filter = '',
201
+                $siteId = 0,
202
+                $shortLinks = false
203 203
     ): Response {
204 204
         PermissionHelper::controllerPermissionCheck('retour:redirects');
205 205
         $data = [];
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
             ->orderBy([$sortField => $sortType])
125 125
             ->filterWhere(['like', 'redirectSrcUrl', $filter])
126 126
             ->orFilterWhere(['like', 'referrerUrl', $filter]);
127
-        if ((int)$siteId !== 0) {
127
+        if ((int) $siteId !== 0) {
128 128
             $query->andWhere(['siteId' => $siteId]);
129 129
         }
130 130
         if ($handled !== 'all') {
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                 }
146 146
                 $stat['addLink'] = '';
147 147
                 if (!$stat['handledByRetour']) {
148
-                    $encodedUrl = urlencode('/' . ltrim($stat['redirectSrcUrl'], '/'));
148
+                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
149 149
                     // Add the siteId to the URL, but keep the current behavior of passing in siteId=0 for "all"
150 150
                     $statSiteId = $stat['siteId'] ?? 0;
151 151
                     try {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                     } catch (SiteNotFoundException $e) {
154 154
                         $primarySite = null;
155 155
                     }
156
-                    if ($primarySite !== null && $statSiteId == (int)$primarySite->id) {
156
+                    if ($primarySite !== null && $statSiteId == (int) $primarySite->id) {
157 157
                         $statSiteId = 0;
158 158
                     }
159 159
                     $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
             ->orderBy([$sortField => $sortType])
229 229
             ->filterWhere(['like', 'redirectSrcUrl', $filter])
230 230
             ->orFilterWhere(['like', 'redirectDestUrl', $filter]);
231
-        if ((int)$siteId !== 0) {
231
+        if ((int) $siteId !== 0) {
232 232
             $query->andWhere(['siteId' => $siteId]);
233 233
         }
234 234
         if ($shortLinks) {
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                 }
271 271
             }
272 272
 
273
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect['id']);
273
+            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
274 274
         }
275 275
         // Format the data for the API
276 276
         if ($redirects) {
Please login to merge, or discard this patch.
src/controllers/FileController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
         $variables['docsUrl'] = self::DOCUMENTATION_URL;
204 204
         $variables['pluginName'] = $pluginName;
205 205
         $variables['title'] = $templateTitle;
206
-        $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';
206
+        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
207 207
         $variables['crumbs'] = [
208 208
             [
209 209
                 'label' => $pluginName,
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
             ],
212 212
             [
213 213
                 'label' => 'Redirects',
214
-                'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri),
214
+                'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri),
215 215
             ],
216 216
         ];
217 217
         $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}";
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
         $file = UploadedFile::getInstanceByName('file');
222 222
         if ($file !== null) {
223 223
             $filename = uniqid($file->name, true);
224
-            $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename;
224
+            $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename;
225 225
             $file->saveAs($filePath, false);
226 226
             // Also save the file to the cache as a backup way to access it
227 227
             $fileContents = @file_get_contents($filePath);
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         }
355 355
         $csv->insertOne(array_values($columns));
356 356
         $csv->insertAll($data);
357
-        $csv->output($filename . '.csv');
357
+        $csv->output($filename.'.csv');
358 358
         exit(0);
359 359
     }
360 360
 
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
                 $index++;
387 387
             }
388 388
             $redirectDump = print_r($redirectConfig, true);
389
-            Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
389
+            Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
390 390
             if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) {
391
-                Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
391
+                Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
392 392
                 $hasErrors = true;
393 393
             }
394 394
             $rowIndex++;
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
                 $index++;
429 429
             }
430 430
             $redirectDump = print_r($redirectConfig, true);
431
-            Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
431
+            Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
432 432
             if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) {
433
-                Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
433
+                Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
434 434
                 $hasErrors = true;
435 435
             }
436 436
             $rowIndex++;
Please login to merge, or discard this patch.