Test Failed
Push — v4 ( e72076...9a8180 )
by Andrew
35:31 queued 15:18
created
src/controllers/FileController.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     // Protected Properties
89 89
     // =========================================================================
90 90
 
91
-    protected array|bool|int $allowAnonymous = [];
91
+    protected array | bool | int $allowAnonymous = [];
92 92
 
93 93
     // Public Methods
94 94
     // =========================================================================
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
                 $index++;
192 192
             }
193 193
             $redirectDump = print_r($redirectConfig, true);
194
-            Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
194
+            Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
195 195
             if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) {
196
-                Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
196
+                Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
197 197
                 $hasErrors = true;
198 198
             }
199 199
             $rowIndex++;
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
                 $index++;
234 234
             }
235 235
             $redirectDump = print_r($redirectConfig, true);
236
-            Craft::debug("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
236
+            Craft::debug("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
237 237
             if (!Retour::$plugin->redirects->saveRedirect($redirectConfig)) {
238
-                Craft::info("-> ROW #$rowIndex contents: " . $redirectDump, __METHOD__);
238
+                Craft::info("-> ROW #$rowIndex contents: ".$redirectDump, __METHOD__);
239 239
                 $hasErrors = true;
240 240
             }
241 241
             $rowIndex++;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         $variables['docsUrl'] = self::DOCUMENTATION_URL;
285 285
         $variables['pluginName'] = $pluginName;
286 286
         $variables['title'] = $templateTitle;
287
-        $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';
287
+        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
288 288
         $variables['crumbs'] = [
289 289
             [
290 290
                 'label' => $pluginName,
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             ],
293 293
             [
294 294
                 'label' => 'Redirects',
295
-                'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri),
295
+                'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri),
296 296
             ],
297 297
         ];
298 298
         $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}";
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
         $file = UploadedFile::getInstanceByName('file');
303 303
         if ($file !== null) {
304 304
             $filename = uniqid($file->name, true);
305
-            $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename;
305
+            $filePath = Craft::$app->getPath()->getTempPath().DIRECTORY_SEPARATOR.$filename;
306 306
             $file->saveAs($filePath, false);
307 307
             // Also save the file to the cache as a backup way to access it
308 308
             $fileContents = @file_get_contents($filePath);
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         }
421 421
         $csv->insertOne(array_values($columns));
422 422
         $csv->insertAll($data);
423
-        $csv->output($filename . '.csv');
423
+        $csv->output($filename.'.csv');
424 424
         exit(0);
425 425
     }
426 426
 
Please login to merge, or discard this patch.
src/controllers/ChartsController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     /**
36 36
      * @inerhitdoc
37 37
      */
38
-    protected array|bool|int $allowAnonymous = [
38
+    protected array | bool | int $allowAnonymous = [
39 39
     ];
40 40
 
41 41
     // Public Methods
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                     'COUNT(handledByRetour = 1 or null) as handled_cnt',
80 80
                 ])
81 81
                 ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )");
82
-            if ((int)$siteId !== 0) {
82
+            if ((int) $siteId !== 0) {
83 83
                 $query->andWhere(['siteId' => $siteId]);
84 84
             }
85 85
             $query
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                     "COUNT(CASE WHEN \"handledByRetour\" = true THEN 1 END) as handled_cnt",
98 98
                 ])
99 99
                 ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )");
100
-            if ((int)$siteId !== 0) {
100
+            if ((int) $siteId !== 0) {
101 101
                 $query->andWhere(['siteId' => $siteId]);
102 102
             }
103 103
             $query
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
         }
162 162
         if ($stats) {
163 163
             $data = [
164
-                (int)$stats,
165
-                (int)$handledStats,
164
+                (int) $stats,
165
+                (int) $handledStats,
166 166
             ];
167 167
         }
168 168
 
Please login to merge, or discard this patch.
src/helpers/UrlHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
         $addSlash = str_ends_with($path, '/');
66 66
         if (!empty($sitePath)) {
67 67
             // Normalizes a URI path by trimming leading/ trailing slashes and removing double slashes
68
-            $sitePath = '/' . preg_replace('/\/\/+/', '/', trim($sitePath, '/'));
68
+            $sitePath = '/'.preg_replace('/\/\/+/', '/', trim($sitePath, '/'));
69 69
         }
70 70
         // Strip the $sitePath from the incoming $path
71 71
         if (str_starts_with($path, $sitePath)) {
72 72
             $path = substr($path, strlen($sitePath));
73
-            $path = '/' . preg_replace('/\/\/+/', '/', trim($path, '/'));
73
+            $path = '/'.preg_replace('/\/\/+/', '/', trim($path, '/'));
74 74
         }
75
-        $path = $addSlash ? $path . '/' : $path;
75
+        $path = $addSlash ? $path.'/' : $path;
76 76
 
77 77
         return $path;
78 78
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $sitePath = parse_url($site->baseUrl, PHP_URL_PATH);
91 91
             if (!empty($sitePath)) {
92 92
                 // Normalizes a URI path by trimming leading/ trailing slashes and removing double slashes
93
-                $sitePath = '/' . preg_replace('/\/\/+/', '/', trim($sitePath, '/'));
93
+                $sitePath = '/'.preg_replace('/\/\/+/', '/', trim($sitePath, '/'));
94 94
             }
95 95
             // See if the path begins with a site path prefix
96 96
             if ($sitePath !== '/' && str_starts_with($path, $sitePath)) {
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
         $overlap = 0;
114 114
         $url = $url ?? '';
115 115
         $path = $path ?? '';
116
-        $url = rtrim($url, '/') . '/';
117
-        $path = '/' . ltrim($path, '/');
116
+        $url = rtrim($url, '/').'/';
117
+        $path = '/'.ltrim($path, '/');
118 118
         $urlOffset = strlen($url);
119 119
         $pathLength = strlen($path);
120 120
         $pathOffset = 0;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             }
127 127
         }
128 128
 
129
-        return rtrim($url, '/') . '/' . ltrim(substr($path, $overlap), '/');
129
+        return rtrim($url, '/').'/'.ltrim(substr($path, $overlap), '/');
130 130
     }
131 131
 
132 132
     /**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         /** @noinspection CallableParameterUseCaseInTypeContextInspection */
147 147
         $url = preg_replace('/{.*}/', '', $url);
148 148
         // Remove any linebreaks that may be errantly in the URL
149
-        $url = (string)str_replace([
149
+        $url = (string) str_replace([
150 150
                 PHP_EOL,
151 151
                 "\r",
152 152
                 "\n",
Please login to merge, or discard this patch.
src/services/Redirects.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
      */
281 281
     public function excludeUri($uri): bool
282 282
     {
283
-        $uri = '/' . ltrim($uri, '/');
283
+        $uri = '/'.ltrim($uri, '/');
284 284
         if (!empty(Retour::$settings->excludePatterns)) {
285 285
             foreach (Retour::$settings->excludePatterns as $excludePattern) {
286 286
                 if (empty($excludePattern['pattern'])) {
287 287
                     continue;
288 288
                 }
289
-                $pattern = '`' . $excludePattern['pattern'] . '`i';
289
+                $pattern = '`'.$excludePattern['pattern'].'`i';
290 290
                 try {
291 291
                     if (preg_match($pattern, $uri) === 1) {
292 292
                         Craft::info(
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                     }
303 303
                 } catch (\Exception $e) {
304 304
                     // That's fine
305
-                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__);
305
+                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__);
306 306
                 }
307 307
             }
308 308
         }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
      *
318 318
      * @return bool|array|null
319 319
      */
320
-    public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool|array|null
320
+    public function findRedirectMatch(string $fullUrl, string $pathOnly, $siteId = null): bool | array | null
321 321
     {
322 322
         // Get the current site
323 323
         if ($siteId === null) {
@@ -370,10 +370,10 @@  discard block
 block discarded – undo
370 370
      *
371 371
      * @return bool|array
372 372
      */
373
-    public function getRedirectFromCache(string $url, int $siteId = 0): bool|array
373
+    public function getRedirectFromCache(string $url, int $siteId = 0): bool | array
374 374
     {
375 375
         $cache = Craft::$app->getCache();
376
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
376
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
377 377
         $redirect = $cache->get($cacheKey);
378 378
         Craft::info(
379 379
             Craft::t(
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                         'id' => $redirectConfig['id'],
419 419
                     ]
420 420
                 )->execute();
421
-                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__);
421
+                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__);
422 422
             } catch (\Exception $e) {
423 423
                 Craft::error($e->getMessage(), __METHOD__);
424 424
             }
@@ -439,12 +439,12 @@  discard block
 block discarded – undo
439 439
         } catch (SiteNotFoundException $e) {
440 440
             $siteId = 1;
441 441
         }
442
-        $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;
442
+        $cacheKey = $this::CACHE_KEY.md5($url).$siteId;
443 443
         // Create the dependency tags
444 444
         $dependency = new TagDependency([
445 445
             'tags' => [
446 446
                 $this::GLOBAL_REDIRECTS_CACHE_TAG,
447
-                $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,
447
+                $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,
448 448
             ],
449 449
         ]);
450 450
         $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
         foreach ($redirects as $redirect) {
639 639
             // Figure out what type of source matching to do
640 640
             $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';
641
-            $redirectEnabled = (bool)$redirect['enabled'];
641
+            $redirectEnabled = (bool) $redirect['enabled'];
642 642
             if ($redirectEnabled === true) {
643 643
                 switch ($redirectSrcMatch) {
644 644
                     case 'pathonly':
@@ -679,12 +679,12 @@  discard block
 block discarded – undo
679 679
 
680 680
                     // Do a regex match
681 681
                     case 'regexmatch':
682
-                        $matchRegEx = '`' . $redirect['redirectSrcUrlParsed'] . '`i';
682
+                        $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';
683 683
                         try {
684 684
                             if (preg_match($matchRegEx, $url) === 1) {
685 685
                                 $this->incrementRedirectHitCount($redirect);
686 686
                                 // If we're not associated with an EntryID, handle capture group replacement
687
-                                if ((int)$redirect['associatedElementId'] === 0) {
687
+                                if ((int) $redirect['associatedElementId'] === 0) {
688 688
                                     $redirect['redirectDestUrl'] = preg_replace(
689 689
                                         $matchRegEx,
690 690
                                         $redirect['redirectDestUrl'],
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
                             }
713 713
                         } catch (\Exception $e) {
714 714
                             // That's fine
715
-                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__);
715
+                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__);
716 716
                         }
717 717
 
718 718
                         break;
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
                     try {
829 829
                         $siteId = $redirect['siteId'] ?? null;
830 830
                         if ($siteId !== null) {
831
-                            $siteId = (int)$siteId;
831
+                            $siteId = (int) $siteId;
832 832
                         }
833 833
                         if (!UrlHelper::isAbsoluteUrl($dest) && !UrlHelper::pathHasSitePrefix($path) && Retour::$settings->resolveCraftSites) {
834 834
                             $dest = UrlHelper::siteUrl('/', null, null, $siteId);
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
                 try {
851 851
                     $siteId = $redirect['siteId'] ?? null;
852 852
                     if ($siteId !== null) {
853
-                        $siteId = (int)$siteId;
853
+                        $siteId = (int) $siteId;
854 854
                     }
855 855
                     $dest = UrlHelper::siteUrl($dest, null, null, $siteId);
856 856
                 } catch (\yii\base\Exception $e) {
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
                     // That's ok
866 866
                 }
867 867
                 if (!empty($queryString)) {
868
-                    $dest = strtok($dest, '?') . '?' . $queryString;
868
+                    $dest = strtok($dest, '?').'?'.$queryString;
869 869
                 }
870 870
             }
871 871
             $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
         foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) {
940 940
             /** @var Plugin $plugin */
941 941
             if (method_exists($plugin, 'retourMatch')) {
942
-                $result[$plugin->getHandle()] = $plugin->name . Craft::t('retour', ' Match');
942
+                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match');
943 943
             }
944 944
         }
945 945
 
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
         $db = Craft::$app->getDb();
977 977
         // Trigger a 'beforeDeleteRedirect' event
978 978
         $redirectConfig = $this->getRedirectById($id);
979
-        $isNew = (int)$redirectConfig['id'] === 0;
979
+        $isNew = (int) $redirectConfig['id'] === 0;
980 980
         $event = new RedirectEvent([
981 981
             'isNew' => $isNew,
982 982
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
         // Get the validated model attributes and save them to the db
1141 1141
         $redirectConfig = $redirect->getAttributes();
1142 1142
         // 0 for a siteId needs to be converted to null
1143
-        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) {
1143
+        if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) {
1144 1144
             $redirectConfig['siteId'] = null;
1145 1145
         }
1146 1146
         // Throw an event to before saving the redirect
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
         }
1151 1151
 
1152 1152
         // See if a redirect exists with this source URL already
1153
-        if ((int)$redirectConfig['id'] === 0) {
1153
+        if ((int) $redirectConfig['id'] === 0) {
1154 1154
             // Query the db table
1155 1155
             $redirect = (new Query())
1156 1156
                 ->from(['{{%retour_static_redirects}}'])
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
             }
1164 1164
         }
1165 1165
         // Trigger a 'beforeSaveRedirect' event
1166
-        $isNew = (int)$redirectConfig['id'] === 0;
1166
+        $isNew = (int) $redirectConfig['id'] === 0;
1167 1167
         $event = new RedirectEvent([
1168 1168
             'isNew' => $isNew,
1169 1169
             'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],
Please login to merge, or discard this patch.