@@ -135,8 +135,8 @@ discard block  | 
                                                    ||
| 135 | 135 | public function rules()  | 
                                                        
| 136 | 136 |      { | 
                                                        
| 137 | 137 | return [  | 
                                                        
| 138 | - ['pluginName', 'string'],  | 
                                                        |
| 139 | - ['pluginName', 'default', 'value' => 'Retour'],  | 
                                                        |
| 138 | + [ 'pluginName', 'string' ],  | 
                                                        |
| 139 | + [ 'pluginName', 'default', 'value' => 'Retour' ],  | 
                                                        |
| 140 | 140 | [  | 
                                                        
| 141 | 141 | [  | 
                                                        
| 142 | 142 | 'createUriChangeRedirects',  | 
                                                        
@@ -147,22 +147,22 @@ discard block  | 
                                                    ||
| 147 | 147 | ],  | 
                                                        
| 148 | 148 | 'boolean',  | 
                                                        
| 149 | 149 | ],  | 
                                                        
| 150 | - ['uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly'],  | 
                                                        |
| 151 | - ['uriChangeRedirectSrcMatch', 'string'],  | 
                                                        |
| 152 | - ['uriChangeRedirectSrcMatch', 'in', 'range' => [  | 
                                                        |
| 150 | + [ 'uriChangeRedirectSrcMatch', 'default', 'value' => 'pathonly' ],  | 
                                                        |
| 151 | + [ 'uriChangeRedirectSrcMatch', 'string' ],  | 
                                                        |
| 152 | + [ 'uriChangeRedirectSrcMatch', 'in', 'range' => [  | 
                                                        |
| 153 | 153 | 'pathonly',  | 
                                                        
| 154 | 154 | 'fullurl'  | 
                                                        
| 155 | - ]],  | 
                                                        |
| 156 | - ['staticRedirectDisplayLimit', 'integer', 'min' => 1],  | 
                                                        |
| 157 | - ['staticRedirectDisplayLimit', 'default', 'value' => 100],  | 
                                                        |
| 158 | - ['dynamicRedirectDisplayLimit', 'integer', 'min' => 1],  | 
                                                        |
| 159 | - ['dynamicRedirectDisplayLimit', 'default', 'value' => 100],  | 
                                                        |
| 160 | - ['statsStoredLimit', 'integer', 'min' => 1],  | 
                                                        |
| 161 | - ['statsStoredLimit', 'default', 'value' => 1000],  | 
                                                        |
| 162 | - ['refreshIntervalSecs', 'integer', 'min' => 0],  | 
                                                        |
| 163 | - ['refreshIntervalSecs', 'default', 'value' => 3],  | 
                                                        |
| 164 | - ['statsDisplayLimit', 'integer', 'min' => 1],  | 
                                                        |
| 165 | - ['statsDisplayLimit', 'default', 'value' => 1000],  | 
                                                        |
| 155 | + ] ],  | 
                                                        |
| 156 | + [ 'staticRedirectDisplayLimit', 'integer', 'min' => 1 ],  | 
                                                        |
| 157 | + [ 'staticRedirectDisplayLimit', 'default', 'value' => 100 ],  | 
                                                        |
| 158 | + [ 'dynamicRedirectDisplayLimit', 'integer', 'min' => 1 ],  | 
                                                        |
| 159 | + [ 'dynamicRedirectDisplayLimit', 'default', 'value' => 100 ],  | 
                                                        |
| 160 | + [ 'statsStoredLimit', 'integer', 'min' => 1 ],  | 
                                                        |
| 161 | + [ 'statsStoredLimit', 'default', 'value' => 1000 ],  | 
                                                        |
| 162 | + [ 'refreshIntervalSecs', 'integer', 'min' => 0 ],  | 
                                                        |
| 163 | + [ 'refreshIntervalSecs', 'default', 'value' => 3 ],  | 
                                                        |
| 164 | + [ 'statsDisplayLimit', 'integer', 'min' => 1 ],  | 
                                                        |
| 165 | + [ 'statsDisplayLimit', 'default', 'value' => 1000 ],  | 
                                                        |
| 166 | 166 | [  | 
                                                        
| 167 | 167 | [  | 
                                                        
| 168 | 168 | 'excludePatterns',  | 
                                                        
@@ -178,7 +178,7 @@ discard block  | 
                                                    ||
| 178 | 178 | */  | 
                                                        
| 179 | 179 | public function behaviors()  | 
                                                        
| 180 | 180 |      { | 
                                                        
| 181 | - $craft31Behaviors = [];  | 
                                                        |
| 181 | + $craft31Behaviors = [ ];  | 
                                                        |
| 182 | 182 |          if (Retour::$craft31) { | 
                                                        
| 183 | 183 | $craft31Behaviors = [  | 
                                                        
| 184 | 184 | 'parser' => [  | 
                                                        
@@ -57,7 +57,7 @@  | 
                                                    ||
| 57 | 57 | // Determines whether the Retour API endpoint should be enabled for anonymous frontend access  | 
                                                        
| 58 | 58 | 'enableApiEndpoint' => false,  | 
                                                        
| 59 | 59 | |
| 60 | - // [Regular expressions](https://regexr.com/) to match URLs to exclude from tracking  | 
                                                        |
| 60 | + // [Regular expressions](https://regexr.com/) to match URLs to exclude from tracking  | 
                                                        |
| 61 | 61 | 'excludePatterns' => [  | 
                                                        
| 62 | 62 | ],  | 
                                                        
| 63 | 63 | |
@@ -190,7 +190,7 @@ discard block  | 
                                                    ||
| 190 | 190 | Craft::t(  | 
                                                        
| 191 | 191 | 'retour',  | 
                                                        
| 192 | 192 |                      '404 full URL: {fullUrl}, 404 path only: {pathOnly}', | 
                                                        
| 193 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly]  | 
                                                        |
| 193 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ]  | 
                                                        |
| 194 | 194 | ),  | 
                                                        
| 195 | 195 | __METHOD__  | 
                                                        
| 196 | 196 | );  | 
                                                        
@@ -224,7 +224,7 @@ discard block  | 
                                                    ||
| 224 | 224 | $response = Craft::$app->getResponse();  | 
                                                        
| 225 | 225 |          if ($redirect !== null) { | 
                                                        
| 226 | 226 | // Figure out what type of source matching was done  | 
                                                        
| 227 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';  | 
                                                        |
| 227 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly';  | 
                                                        |
| 228 | 228 |              switch ($redirectSrcMatch) { | 
                                                        
| 229 | 229 | case 'pathonly':  | 
                                                        
| 230 | 230 | $url = $pathOnly;  | 
                                                        
@@ -236,13 +236,13 @@ discard block  | 
                                                    ||
| 236 | 236 | $url = $pathOnly;  | 
                                                        
| 237 | 237 | break;  | 
                                                        
| 238 | 238 | }  | 
                                                        
| 239 | - $dest = $redirect['redirectDestUrl'];  | 
                                                        |
| 239 | + $dest = $redirect[ 'redirectDestUrl' ];  | 
                                                        |
| 240 | 240 | // If this isn't a full URL, make it one based on the appropriate site  | 
                                                        
| 241 | 241 |              if (!UrlHelper::isFullUrl($dest)) { | 
                                                        
| 242 | 242 |                  try { | 
                                                        
| 243 | - $siteId = $redirect['siteId'] ?? null;  | 
                                                        |
| 243 | + $siteId = $redirect[ 'siteId' ] ?? null;  | 
                                                        |
| 244 | 244 |                      if ($siteId !== null) { | 
                                                        
| 245 | - $siteId = (int)$siteId;  | 
                                                        |
| 245 | + $siteId = (int) $siteId;  | 
                                                        |
| 246 | 246 | }  | 
                                                        
| 247 | 247 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId);  | 
                                                        
| 248 | 248 |                  } catch (\yii\base\Exception $e) { | 
                                                        
@@ -254,17 +254,17 @@ discard block  | 
                                                    ||
| 254 | 254 | $dest .= '?' . $request->getQueryStringWithoutPath();  | 
                                                        
| 255 | 255 | }  | 
                                                        
| 256 | 256 | }  | 
                                                        
| 257 | - $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';  | 
                                                        |
| 257 | + $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound';  | 
                                                        |
| 258 | 258 | // Parse reference tags for exact matches  | 
                                                        
| 259 | 259 |              if ($redirectMatchType === 'exactmatch') { | 
                                                        
| 260 | - $dest = Craft::$app->elements->parseRefs($dest, $redirect['siteId'] ?? null);  | 
                                                        |
| 260 | + $dest = Craft::$app->elements->parseRefs($dest, $redirect[ 'siteId' ] ?? null);  | 
                                                        |
| 261 | 261 | }  | 
                                                        
| 262 | - $status = $redirect['redirectHttpCode'];  | 
                                                        |
| 262 | + $status = $redirect[ 'redirectHttpCode' ];  | 
                                                        |
| 263 | 263 | Craft::info(  | 
                                                        
| 264 | 264 | Craft::t(  | 
                                                        
| 265 | 265 | 'retour',  | 
                                                        
| 266 | 266 |                      'Redirecting {url} to {dest} with status {status}', | 
                                                        
| 267 | - ['url' => $url, 'dest' => $dest, 'status' => $status]  | 
                                                        |
| 267 | + [ 'url' => $url, 'dest' => $dest, 'status' => $status ]  | 
                                                        |
| 268 | 268 | ),  | 
                                                        
| 269 | 269 | __METHOD__  | 
                                                        
| 270 | 270 | );  | 
                                                        
@@ -288,7 +288,7 @@ discard block  | 
                                                    ||
| 288 | 288 | // Add any additional headers  | 
                                                        
| 289 | 289 |              if (!empty(Retour::$settings->additionalHeaders)) { | 
                                                        
| 290 | 290 |                  foreach (Retour::$settings->additionalHeaders as $additionalHeader) { | 
                                                        
| 291 | - $response->headers->add($additionalHeader['name'], $additionalHeader['value']);  | 
                                                        |
| 291 | + $response->headers->add($additionalHeader[ 'name' ], $additionalHeader[ 'value' ]);  | 
                                                        |
| 292 | 292 | }  | 
                                                        
| 293 | 293 | }  | 
                                                        
| 294 | 294 | // Redirect the request away;  | 
                                                        
@@ -354,13 +354,13 @@ discard block  | 
                                                    ||
| 354 | 354 | public function getRedirectFromCache($url, int $siteId = 0)  | 
                                                        
| 355 | 355 |      { | 
                                                        
| 356 | 356 | $cache = Craft::$app->getCache();  | 
                                                        
| 357 | - $cacheKey = $this::CACHE_KEY.md5($url).$siteId;  | 
                                                        |
| 357 | + $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;  | 
                                                        |
| 358 | 358 | $redirect = $cache->get($cacheKey);  | 
                                                        
| 359 | 359 | Craft::info(  | 
                                                        
| 360 | 360 | Craft::t(  | 
                                                        
| 361 | 361 | 'retour',  | 
                                                        
| 362 | 362 |                  'Cached redirect hit for {url}', | 
                                                        
| 363 | - ['url' => $url]  | 
                                                        |
| 363 | + [ 'url' => $url ]  | 
                                                        |
| 364 | 364 | ),  | 
                                                        
| 365 | 365 | __METHOD__  | 
                                                        
| 366 | 366 | );  | 
                                                        
@@ -382,12 +382,12 @@ discard block  | 
                                                    ||
| 382 | 382 |          } catch (SiteNotFoundException $e) { | 
                                                        
| 383 | 383 | $siteId = 1;  | 
                                                        
| 384 | 384 | }  | 
                                                        
| 385 | - $cacheKey = $this::CACHE_KEY.md5($url).$siteId;  | 
                                                        |
| 385 | + $cacheKey = $this::CACHE_KEY . md5($url) . $siteId;  | 
                                                        |
| 386 | 386 | // Create the dependency tags  | 
                                                        
| 387 | 387 | $dependency = new TagDependency([  | 
                                                        
| 388 | 388 | 'tags' => [  | 
                                                        
| 389 | 389 | $this::GLOBAL_REDIRECTS_CACHE_TAG,  | 
                                                        
| 390 | - $this::GLOBAL_REDIRECTS_CACHE_TAG.$siteId,  | 
                                                        |
| 390 | + $this::GLOBAL_REDIRECTS_CACHE_TAG . $siteId,  | 
                                                        |
| 391 | 391 | ],  | 
                                                        
| 392 | 392 | ]);  | 
                                                        
| 393 | 393 | $cache->set($cacheKey, $redirect, Retour::$cacheDuration, $dependency);  | 
                                                        
@@ -395,7 +395,7 @@ discard block  | 
                                                    ||
| 395 | 395 | Craft::t(  | 
                                                        
| 396 | 396 | 'retour',  | 
                                                        
| 397 | 397 |                  'Cached redirect saved for {url}', | 
                                                        
| 398 | - ['url' => $url]  | 
                                                        |
| 398 | + [ 'url' => $url ]  | 
                                                        |
| 399 | 399 | ),  | 
                                                        
| 400 | 400 | __METHOD__  | 
                                                        
| 401 | 401 | );  | 
                                                        
@@ -425,8 +425,8 @@ discard block  | 
                                                    ||
| 425 | 425 | // Iterate through the redirects  | 
                                                        
| 426 | 426 |          foreach ($redirects as $redirect) { | 
                                                        
| 427 | 427 | // Figure out what type of source matching to do  | 
                                                        
| 428 | - $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly';  | 
                                                        |
| 429 | - $redirectEnabled = (bool)$redirect['enabled'];  | 
                                                        |
| 428 | + $redirectSrcMatch = $redirect[ 'redirectSrcMatch' ] ?? 'pathonly';  | 
                                                        |
| 429 | + $redirectEnabled = (bool) $redirect[ 'enabled' ];  | 
                                                        |
| 430 | 430 |              if ($redirectEnabled === true) { | 
                                                        
| 431 | 431 |                  switch ($redirectSrcMatch) { | 
                                                        
| 432 | 432 | case 'pathonly':  | 
                                                        
@@ -439,11 +439,11 @@ discard block  | 
                                                    ||
| 439 | 439 | $url = $pathOnly;  | 
                                                        
| 440 | 440 | break;  | 
                                                        
| 441 | 441 | }  | 
                                                        
| 442 | - $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound';  | 
                                                        |
| 442 | + $redirectMatchType = $redirect[ 'redirectMatchType' ] ?? 'notfound';  | 
                                                        |
| 443 | 443 |                  switch ($redirectMatchType) { | 
                                                        
| 444 | 444 | // Do a straight up match  | 
                                                        
| 445 | 445 | case 'exactmatch':  | 
                                                        
| 446 | -                        if (strcasecmp($redirect['redirectSrcUrlParsed'], $url) === 0) { | 
                                                        |
| 446 | +                        if (strcasecmp($redirect[ 'redirectSrcUrlParsed' ], $url) === 0) { | 
                                                        |
| 447 | 447 | $this->incrementRedirectHitCount($redirect);  | 
                                                        
| 448 | 448 | $this->saveRedirectToCache($url, $redirect);  | 
                                                        
| 449 | 449 | |
@@ -466,15 +466,15 @@ discard block  | 
                                                    ||
| 466 | 466 | |
| 467 | 467 | // Do a regex match  | 
                                                        
| 468 | 468 | case 'regexmatch':  | 
                                                        
| 469 | - $matchRegEx = '`'.$redirect['redirectSrcUrlParsed'].'`i';  | 
                                                        |
| 469 | + $matchRegEx = '`' . $redirect[ 'redirectSrcUrlParsed' ] . '`i';  | 
                                                        |
| 470 | 470 |                          try { | 
                                                        
| 471 | 471 |                              if (preg_match($matchRegEx, $url) === 1) { | 
                                                        
| 472 | 472 | $this->incrementRedirectHitCount($redirect);  | 
                                                        
| 473 | 473 | // If we're not associated with an EntryID, handle capture group replacement  | 
                                                        
| 474 | -                                if ((int)$redirect['associatedElementId'] === 0) { | 
                                                        |
| 475 | - $redirect['redirectDestUrl'] = preg_replace(  | 
                                                        |
| 474 | +                                if ((int) $redirect[ 'associatedElementId' ] === 0) { | 
                                                        |
| 475 | + $redirect[ 'redirectDestUrl' ] = preg_replace(  | 
                                                        |
| 476 | 476 | $matchRegEx,  | 
                                                        
| 477 | - $redirect['redirectDestUrl'],  | 
                                                        |
| 477 | + $redirect[ 'redirectDestUrl' ],  | 
                                                        |
| 478 | 478 | $url  | 
                                                        
| 479 | 479 | );  | 
                                                        
| 480 | 480 | }  | 
                                                        
@@ -498,7 +498,7 @@ discard block  | 
                                                    ||
| 498 | 498 | }  | 
                                                        
| 499 | 499 |                          } catch (\Exception $e) { | 
                                                        
| 500 | 500 | // That's fine  | 
                                                        
| 501 | -                            Craft::error('Invalid Redirect Regex: '.$matchRegEx, __METHOD__); | 
                                                        |
| 501 | +                            Craft::error('Invalid Redirect Regex: ' . $matchRegEx, __METHOD__); | 
                                                        |
| 502 | 502 | }  | 
                                                        
| 503 | 503 | |
| 504 | 504 | break;  | 
                                                        
@@ -512,7 +512,7 @@ discard block  | 
                                                    ||
| 512 | 512 | 'redirect' => &$redirect,  | 
                                                        
| 513 | 513 | ],  | 
                                                        
| 514 | 514 | ];  | 
                                                        
| 515 | - $result = \call_user_func_array([$plugin, 'retourMatch'], $args);  | 
                                                        |
| 515 | + $result = \call_user_func_array([ $plugin, 'retourMatch' ], $args);  | 
                                                        |
| 516 | 516 |                              if ($result) { | 
                                                        
| 517 | 517 | $this->incrementRedirectHitCount($redirect);  | 
                                                        
| 518 | 518 | $this->saveRedirectToCache($url, $redirect);  | 
                                                        
@@ -552,7 +552,7 @@ discard block  | 
                                                    ||
| 552 | 552 | Craft::t(  | 
                                                        
| 553 | 553 | 'retour',  | 
                                                        
| 554 | 554 |                  'Not handled-> full URL: {fullUrl}, path only: {pathOnly}', | 
                                                        
| 555 | - ['fullUrl' => $fullUrl, 'pathOnly' => $pathOnly]  | 
                                                        |
| 555 | + [ 'fullUrl' => $fullUrl, 'pathOnly' => $pathOnly ]  | 
                                                        |
| 556 | 556 | ),  | 
                                                        
| 557 | 557 | __METHOD__  | 
                                                        
| 558 | 558 | );  | 
                                                        
@@ -597,7 +597,7 @@ discard block  | 
                                                    ||
| 597 | 597 |          foreach (Craft::$app->getPlugins()->getAllPlugins() as $plugin) { | 
                                                        
| 598 | 598 | /** @var Plugin $plugin */  | 
                                                        
| 599 | 599 |              if (method_exists($plugin, 'retourMatch')) { | 
                                                        
| 600 | -                $result[$plugin->getHandle()] = $plugin->name.Craft::t('retour', ' Match'); | 
                                                        |
| 600 | +                $result[ $plugin->getHandle() ] = $plugin->name . Craft::t('retour', ' Match'); | 
                                                        |
| 601 | 601 | }  | 
                                                        
| 602 | 602 | }  | 
                                                        
| 603 | 603 | |
@@ -618,12 +618,12 @@ discard block  | 
                                                    ||
| 618 | 618 | }  | 
                                                        
| 619 | 619 | // Query the db table  | 
                                                        
| 620 | 620 | $query = (new Query())  | 
                                                        
| 621 | -            ->from(['{{%retour_static_redirects}}']) | 
                                                        |
| 621 | +            ->from([ '{{%retour_static_redirects}}' ]) | 
                                                        |
| 622 | 622 |              ->orderBy('redirectMatchType ASC, redirectSrcMatch ASC, hitCount DESC'); | 
                                                        
| 623 | 623 |          if ($siteId) { | 
                                                        
| 624 | 624 | $query  | 
                                                        
| 625 | - ->where(['siteId' => $siteId])  | 
                                                        |
| 626 | - ->orWhere(['siteId' => null]);  | 
                                                        |
| 625 | + ->where([ 'siteId' => $siteId ])  | 
                                                        |
| 626 | + ->orWhere([ 'siteId' => null ]);  | 
                                                        |
| 627 | 627 | }  | 
                                                        
| 628 | 628 |          if ($limit) { | 
                                                        
| 629 | 629 | $query->limit($limit);  | 
                                                        
@@ -646,8 +646,8 @@ discard block  | 
                                                    ||
| 646 | 646 |      { | 
                                                        
| 647 | 647 | // Query the db table  | 
                                                        
| 648 | 648 | $redirect = (new Query())  | 
                                                        
| 649 | -            ->from(['{{%retour_static_redirects}}']) | 
                                                        |
| 650 | - ->where(['id' => $id])  | 
                                                        |
| 649 | +            ->from([ '{{%retour_static_redirects}}' ]) | 
                                                        |
| 650 | + ->where([ 'id' => $id ])  | 
                                                        |
| 651 | 651 | ->one();  | 
                                                        
| 652 | 652 | |
| 653 | 653 | return $redirect;  | 
                                                        
@@ -665,16 +665,16 @@ discard block  | 
                                                    ||
| 665 | 665 |      { | 
                                                        
| 666 | 666 | // Query the db table  | 
                                                        
| 667 | 667 | $query = (new Query())  | 
                                                        
| 668 | -            ->from(['{{%retour_static_redirects}}']) | 
                                                        |
| 669 | - ->where(['redirectSrcUrl' => $redirectSrcUrl])  | 
                                                        |
| 668 | +            ->from([ '{{%retour_static_redirects}}' ]) | 
                                                        |
| 669 | + ->where([ 'redirectSrcUrl' => $redirectSrcUrl ])  | 
                                                        |
| 670 | 670 | ;  | 
                                                        
| 671 | 671 |          if ($siteId) { | 
                                                        
| 672 | 672 | $query  | 
                                                        
| 673 | - ->andWhere(['or', [  | 
                                                        |
| 673 | + ->andWhere([ 'or', [  | 
                                                        |
| 674 | 674 | 'siteId' => $siteId,  | 
                                                        
| 675 | 675 | ], [  | 
                                                        
| 676 | 676 | 'siteId' => null,  | 
                                                        
| 677 | - ]]);  | 
                                                        |
| 677 | + ] ]);  | 
                                                        |
| 678 | 678 | }  | 
                                                        
| 679 | 679 | $redirect = $query->one();  | 
                                                        
| 680 | 680 | |
@@ -716,13 +716,13 @@ discard block  | 
                                                    ||
| 716 | 716 |      { | 
                                                        
| 717 | 717 |          if ($redirectConfig !== null) { | 
                                                        
| 718 | 718 | $db = Craft::$app->getDb();  | 
                                                        
| 719 | - $redirectConfig['hitCount']++;  | 
                                                        |
| 720 | - $redirectConfig['hitLastTime'] = Db::prepareDateForDb(new \DateTime());  | 
                                                        |
| 719 | + $redirectConfig[ 'hitCount' ]++;  | 
                                                        |
| 720 | + $redirectConfig[ 'hitLastTime' ] = Db::prepareDateForDb(new \DateTime());  | 
                                                        |
| 721 | 721 | Craft::debug(  | 
                                                        
| 722 | 722 | Craft::t(  | 
                                                        
| 723 | 723 | 'retour',  | 
                                                        
| 724 | 724 |                      'Incrementing statistics for: {redirect}', | 
                                                        
| 725 | - ['redirect' => print_r($redirectConfig, true)]  | 
                                                        |
| 725 | + [ 'redirect' => print_r($redirectConfig, true) ]  | 
                                                        |
| 726 | 726 | ),  | 
                                                        
| 727 | 727 | __METHOD__  | 
                                                        
| 728 | 728 | );  | 
                                                        
@@ -731,14 +731,14 @@ discard block  | 
                                                    ||
| 731 | 731 | $rowsAffected = $db->createCommand()->update(  | 
                                                        
| 732 | 732 |                      '{{%retour_static_redirects}}', | 
                                                        
| 733 | 733 | [  | 
                                                        
| 734 | - 'hitCount' => $redirectConfig['hitCount'],  | 
                                                        |
| 735 | - 'hitLastTime' => $redirectConfig['hitLastTime'],  | 
                                                        |
| 734 | + 'hitCount' => $redirectConfig[ 'hitCount' ],  | 
                                                        |
| 735 | + 'hitLastTime' => $redirectConfig[ 'hitLastTime' ],  | 
                                                        |
| 736 | 736 | ],  | 
                                                        
| 737 | 737 | [  | 
                                                        
| 738 | - 'id' => $redirectConfig['id'],  | 
                                                        |
| 738 | + 'id' => $redirectConfig[ 'id' ],  | 
                                                        |
| 739 | 739 | ]  | 
                                                        
| 740 | 740 | )->execute();  | 
                                                        
| 741 | -                Craft::debug('Rows affected: '.$rowsAffected, __METHOD__); | 
                                                        |
| 741 | +                Craft::debug('Rows affected: ' . $rowsAffected, __METHOD__); | 
                                                        |
| 742 | 742 |              } catch (\Exception $e) { | 
                                                        
| 743 | 743 | Craft::error($e->getMessage(), __METHOD__);  | 
                                                        
| 744 | 744 | }  | 
                                                        
@@ -757,7 +757,7 @@ discard block  | 
                                                    ||
| 757 | 757 | Craft::t(  | 
                                                        
| 758 | 758 | 'retour',  | 
                                                        
| 759 | 759 |                      'Error validating redirect {id}: {errors}', | 
                                                        
| 760 | - ['id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true)]  | 
                                                        |
| 760 | + [ 'id' => $redirect->id, 'errors' => print_r($redirect->getErrors(), true) ]  | 
                                                        |
| 761 | 761 | ),  | 
                                                        
| 762 | 762 | __METHOD__  | 
                                                        
| 763 | 763 | );  | 
                                                        
@@ -767,32 +767,32 @@ discard block  | 
                                                    ||
| 767 | 767 | // Get the validated model attributes and save them to the db  | 
                                                        
| 768 | 768 | $redirectConfig = $redirect->getAttributes();  | 
                                                        
| 769 | 769 | // 0 for a siteId needs to be converted to null  | 
                                                        
| 770 | -        if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { | 
                                                        |
| 771 | - $redirectConfig['siteId'] = null;  | 
                                                        |
| 770 | +        if (empty($redirectConfig[ 'siteId' ]) || (int) $redirectConfig[ 'siteId' ] === 0) { | 
                                                        |
| 771 | + $redirectConfig[ 'siteId' ] = null;  | 
                                                        |
| 772 | 772 | }  | 
                                                        
| 773 | 773 | // Throw an event to before saving the redirect  | 
                                                        
| 774 | 774 | $db = Craft::$app->getDb();  | 
                                                        
| 775 | 775 | // See if a redirect exists with this source URL already  | 
                                                        
| 776 | -        if ((int)$redirectConfig['id'] === 0) { | 
                                                        |
| 776 | +        if ((int) $redirectConfig[ 'id' ] === 0) { | 
                                                        |
| 777 | 777 | // Query the db table  | 
                                                        
| 778 | 778 | $redirect = (new Query())  | 
                                                        
| 779 | -                ->from(['{{%retour_static_redirects}}']) | 
                                                        |
| 780 | - ->where(['redirectSrcUrlParsed' => $redirectConfig['redirectSrcUrlParsed']])  | 
                                                        |
| 781 | - ->andWhere(['siteId' => $redirectConfig['siteId']])  | 
                                                        |
| 779 | +                ->from([ '{{%retour_static_redirects}}' ]) | 
                                                        |
| 780 | + ->where([ 'redirectSrcUrlParsed' => $redirectConfig[ 'redirectSrcUrlParsed' ] ])  | 
                                                        |
| 781 | + ->andWhere([ 'siteId' => $redirectConfig[ 'siteId' ] ])  | 
                                                        |
| 782 | 782 | ->one();  | 
                                                        
| 783 | 783 | // If it exists, update it rather than having duplicates  | 
                                                        
| 784 | 784 |              if (!empty($redirect)) { | 
                                                        
| 785 | - $redirectConfig['id'] = $redirect['id'];  | 
                                                        |
| 785 | + $redirectConfig[ 'id' ] = $redirect[ 'id' ];  | 
                                                        |
| 786 | 786 | }  | 
                                                        
| 787 | 787 | }  | 
                                                        
| 788 | 788 | // Trigger a 'beforeSaveRedirect' event  | 
                                                        
| 789 | - $isNew = (int)$redirectConfig['id'] === 0;  | 
                                                        |
| 789 | + $isNew = (int) $redirectConfig[ 'id' ] === 0;  | 
                                                        |
| 790 | 790 | $event = new RedirectEvent([  | 
                                                        
| 791 | 791 | 'isNew' => $isNew,  | 
                                                        
| 792 | - 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'],  | 
                                                        |
| 793 | - 'destinationUrl' => $redirectConfig['redirectDestUrl'],  | 
                                                        |
| 794 | - 'matchType' => $redirectConfig['redirectSrcMatch'],  | 
                                                        |
| 795 | - 'redirectType' => $redirectConfig['redirectHttpCode'],  | 
                                                        |
| 792 | + 'legacyUrl' => $redirectConfig[ 'redirectSrcUrlParsed' ],  | 
                                                        |
| 793 | + 'destinationUrl' => $redirectConfig[ 'redirectDestUrl' ],  | 
                                                        |
| 794 | + 'matchType' => $redirectConfig[ 'redirectSrcMatch' ],  | 
                                                        |
| 795 | + 'redirectType' => $redirectConfig[ 'redirectHttpCode' ],  | 
                                                        |
| 796 | 796 | ]);  | 
                                                        
| 797 | 797 | $this->trigger(self::EVENT_BEFORE_SAVE_REDIRECT, $event);  | 
                                                        
| 798 | 798 |          if (!$event->isValid) { | 
                                                        
@@ -804,7 +804,7 @@ discard block  | 
                                                    ||
| 804 | 804 | Craft::t(  | 
                                                        
| 805 | 805 | 'retour',  | 
                                                        
| 806 | 806 |                      'Updating existing redirect: {redirect}', | 
                                                        
| 807 | - ['redirect' => print_r($redirectConfig, true)]  | 
                                                        |
| 807 | + [ 'redirect' => print_r($redirectConfig, true) ]  | 
                                                        |
| 808 | 808 | ),  | 
                                                        
| 809 | 809 | __METHOD__  | 
                                                        
| 810 | 810 | );  | 
                                                        
@@ -814,7 +814,7 @@ discard block  | 
                                                    ||
| 814 | 814 |                      '{{%retour_static_redirects}}', | 
                                                        
| 815 | 815 | $redirectConfig,  | 
                                                        
| 816 | 816 | [  | 
                                                        
| 817 | - 'id' => $redirectConfig['id'],  | 
                                                        |
| 817 | + 'id' => $redirectConfig[ 'id' ],  | 
                                                        |
| 818 | 818 | ]  | 
                                                        
| 819 | 819 | )->execute();  | 
                                                        
| 820 | 820 |              } catch (Exception $e) { | 
                                                        
@@ -825,11 +825,11 @@ discard block  | 
                                                    ||
| 825 | 825 | Craft::t(  | 
                                                        
| 826 | 826 | 'retour',  | 
                                                        
| 827 | 827 |                      'Creating new redirect: {redirect}', | 
                                                        
| 828 | - ['redirect' => print_r($redirectConfig, true)]  | 
                                                        |
| 828 | + [ 'redirect' => print_r($redirectConfig, true) ]  | 
                                                        |
| 829 | 829 | ),  | 
                                                        
| 830 | 830 | __METHOD__  | 
                                                        
| 831 | 831 | );  | 
                                                        
| 832 | - unset($redirectConfig['id']);  | 
                                                        |
| 832 | + unset($redirectConfig[ 'id' ]);  | 
                                                        |
| 833 | 833 | // Create a new record  | 
                                                        
| 834 | 834 |              try { | 
                                                        
| 835 | 835 | $db->createCommand()->insert(  | 
                                                        
@@ -842,15 +842,15 @@ discard block  | 
                                                    ||
| 842 | 842 | }  | 
                                                        
| 843 | 843 | // To prevent redirect loops, see if any static redirects have our redirectDestUrl as their redirectSrcUrl  | 
                                                        
| 844 | 844 | $testRedirectConfig = $this->getRedirectByRedirectSrcUrl(  | 
                                                        
| 845 | - $redirectConfig['redirectDestUrl'],  | 
                                                        |
| 846 | - $redirectConfig['siteId']  | 
                                                        |
| 845 | + $redirectConfig[ 'redirectDestUrl' ],  | 
                                                        |
| 846 | + $redirectConfig[ 'siteId' ]  | 
                                                        |
| 847 | 847 | );  | 
                                                        
| 848 | 848 |          if ($testRedirectConfig !== null) { | 
                                                        
| 849 | 849 | Craft::debug(  | 
                                                        
| 850 | 850 | Craft::t(  | 
                                                        
| 851 | 851 | 'retour',  | 
                                                        
| 852 | 852 |                      'Deleting redirect to prevent a loop: {redirect}', | 
                                                        
| 853 | - ['redirect' => print_r($testRedirectConfig, true)]  | 
                                                        |
| 853 | + [ 'redirect' => print_r($testRedirectConfig, true) ]  | 
                                                        |
| 854 | 854 | ),  | 
                                                        
| 855 | 855 | __METHOD__  | 
                                                        
| 856 | 856 | );  | 
                                                        
@@ -858,7 +858,7 @@ discard block  | 
                                                    ||
| 858 | 858 |              try { | 
                                                        
| 859 | 859 | $db->createCommand()->delete(  | 
                                                        
| 860 | 860 |                      '{{%retour_static_redirects}}', | 
                                                        
| 861 | - ['id' => $testRedirectConfig['id']]  | 
                                                        |
| 861 | + [ 'id' => $testRedirectConfig[ 'id' ] ]  | 
                                                        |
| 862 | 862 | )->execute();  | 
                                                        
| 863 | 863 |              } catch (Exception $e) { | 
                                                        
| 864 | 864 | Craft::error($e->getMessage(), __METHOD__);  | 
                                                        
@@ -891,17 +891,17 @@ discard block  | 
                                                    ||
| 891 | 891 | */  | 
                                                        
| 892 | 892 | public function excludeUri($uri): bool  | 
                                                        
| 893 | 893 |      { | 
                                                        
| 894 | - $uri = '/'.ltrim($uri, '/');  | 
                                                        |
| 894 | + $uri = '/' . ltrim($uri, '/');  | 
                                                        |
| 895 | 895 |          if (!empty(Retour::$settings->excludePatterns)) { | 
                                                        
| 896 | 896 |              foreach (Retour::$settings->excludePatterns as $excludePattern) { | 
                                                        
| 897 | - $pattern = '`'.$excludePattern['pattern'].'`i';  | 
                                                        |
| 897 | + $pattern = '`' . $excludePattern[ 'pattern' ] . '`i';  | 
                                                        |
| 898 | 898 |                  try { | 
                                                        
| 899 | 899 |                      if (preg_match($pattern, $uri) === 1) { | 
                                                        
| 900 | 900 | return true;  | 
                                                        
| 901 | 901 | }  | 
                                                        
| 902 | 902 |                  } catch (\Exception $e) { | 
                                                        
| 903 | 903 | // That's fine  | 
                                                        
| 904 | -                    Craft::error('Invalid exclude URI Regex: '.$pattern, __METHOD__); | 
                                                        |
| 904 | +                    Craft::error('Invalid exclude URI Regex: ' . $pattern, __METHOD__); | 
                                                        |
| 905 | 905 | }  | 
                                                        
| 906 | 906 | }  | 
                                                        
| 907 | 907 | }  |