@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | if (!empty($string)) { |
45 | 45 | $string = strip_tags($string); |
46 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
46 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $result; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | if (!empty($string)) { |
69 | 69 | $string = strip_tags($string); |
70 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
70 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $result; |
@@ -39,7 +39,7 @@ |
||
39 | 39 | /** @noinspection CallableParameterUseCaseInTypeContextInspection */ |
40 | 40 | $url = preg_replace('/{.*}/', '', $url); |
41 | 41 | // Remove any linebreaks that may be errantly in the URL |
42 | - $url = (string)str_replace([ |
|
42 | + $url = (string) str_replace([ |
|
43 | 43 | PHP_EOL, |
44 | 44 | "\r", |
45 | 45 | "\n", |
@@ -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 |
@@ -206,7 +206,7 @@ |
||
206 | 206 | ->orderBy([$sortField => $sortType]) |
207 | 207 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
208 | 208 | ->orFilterWhere(['like', 'redirectDestUrl', $filter]) |
209 | - ; |
|
209 | + ; |
|
210 | 210 | if ((int)$siteId !== 0) { |
211 | 211 | $query->andWhere(['siteId' => $siteId]); |
212 | 212 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
125 | 125 | ->orFilterWhere(['like', 'referrerUrl', $filter]) |
126 | 126 | ; |
127 | - if ((int)$siteId !== 0) { |
|
127 | + if ((int) $siteId !== 0) { |
|
128 | 128 | $query->andWhere(['siteId' => $siteId]); |
129 | 129 | } |
130 | 130 | if ($handled !== 'all') { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | } catch (SiteNotFoundException $e) { |
145 | 145 | $primarySite = null; |
146 | 146 | } |
147 | - if ($primarySite !== null && $statSiteId == (int)$primarySite->id) { |
|
147 | + if ($primarySite !== null && $statSiteId == (int) $primarySite->id) { |
|
148 | 148 | $statSiteId = 0; |
149 | 149 | } |
150 | 150 | $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
220 | 220 | ->orFilterWhere(['like', 'redirectDestUrl', $filter]) |
221 | 221 | ; |
222 | - if ((int)$siteId !== 0) { |
|
222 | + if ((int) $siteId !== 0) { |
|
223 | 223 | $query->andWhere(['siteId' => $siteId]); |
224 | 224 | } |
225 | 225 | $redirects = $query->all(); |
@@ -5,12 +5,12 @@ |
||
5 | 5 | ini_set('date.timezone', 'UTC'); |
6 | 6 | |
7 | 7 | // Use the current installation of Craft |
8 | -define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage'); |
|
9 | -define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates'); |
|
10 | -define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config'); |
|
11 | -define('CRAFT_MIGRATIONS_PATH', __DIR__ . '/_craft/migrations'); |
|
12 | -define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations'); |
|
13 | -define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor'); |
|
8 | +define('CRAFT_STORAGE_PATH', __DIR__.'/_craft/storage'); |
|
9 | +define('CRAFT_TEMPLATES_PATH', __DIR__.'/_craft/templates'); |
|
10 | +define('CRAFT_CONFIG_PATH', __DIR__.'/_craft/config'); |
|
11 | +define('CRAFT_MIGRATIONS_PATH', __DIR__.'/_craft/migrations'); |
|
12 | +define('CRAFT_TRANSLATIONS_PATH', __DIR__.'/_craft/translations'); |
|
13 | +define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); |
|
14 | 14 | define('CRAFT_TESTS_PATH', __DIR__); |
15 | 15 | |
16 | 16 | $devMode = true; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | if (strcmp($oldUri, $newUri) !== 0) { |
103 | 103 | // Handle trailing slash config setting |
104 | 104 | if (Craft::$app->config->general->addTrailingSlashesToUrls) { |
105 | - $oldUri = rtrim($oldUri, '/') . '/'; |
|
106 | - $newUri = rtrim($newUri, '/') . '/'; |
|
105 | + $oldUri = rtrim($oldUri, '/').'/'; |
|
106 | + $newUri = rtrim($newUri, '/').'/'; |
|
107 | 107 | } |
108 | 108 | // Handle the URL match type |
109 | 109 | if (Retour::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
110 | 110 | try { |
111 | 111 | if ($redirectSiteId !== null) { |
112 | - $redirectSiteId = (int)$redirectSiteId; |
|
112 | + $redirectSiteId = (int) $redirectSiteId; |
|
113 | 113 | } |
114 | 114 | $oldUri = \craft\helpers\UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
115 | 115 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'siteId' => $redirectSiteId, |
128 | 128 | ]; |
129 | 129 | // Trigger a 'beforeSaveEntryRedirect' event |
130 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
130 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
131 | 131 | $event = new RedirectEvent([ |
132 | 132 | 'isNew' => $isNew, |
133 | 133 | 'legacyUrl' => $redirectConfig['redirectSrcUrl'], |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getRecentStatistics($days = 1, $handled = false): array |
80 | 80 | { |
81 | 81 | // Ensure is an int |
82 | - $handledInt = (int)$handled; |
|
82 | + $handledInt = (int) $handled; |
|
83 | 83 | $stats = []; |
84 | 84 | $db = Craft::$app->getDb(); |
85 | 85 | if ($db->getIsMysql()) { |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | $stats->userAgent = $userAgent; |
211 | 211 | $stats->exceptionMessage = $exceptionMessage; |
212 | 212 | $stats->exceptionFilePath = $exceptionFilePath; |
213 | - $stats->exceptionFileLine = (int)$exceptionFileLine; |
|
213 | + $stats->exceptionFileLine = (int) $exceptionFileLine; |
|
214 | 214 | $stats->hitLastTime = Db::prepareDateForDb(new \DateTime()); |
215 | - $stats->handledByRetour = (int)$handled; |
|
215 | + $stats->handledByRetour = (int) $handled; |
|
216 | 216 | $stats->hitCount++; |
217 | 217 | $statsConfig = $stats->getAttributes(); |
218 | 218 | // Record the updated statistics |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $now = round(microtime(true) * 1000); |
357 | 357 | $cache = Craft::$app->getCache(); |
358 | 358 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); |
359 | - if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { |
|
359 | + if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { |
|
360 | 360 | $limited = true; |
361 | 361 | } |
362 | 362 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | try { |
245 | 245 | $siteId = $redirect['siteId'] ?? null; |
246 | 246 | if ($siteId !== null) { |
247 | - $siteId = (int)$siteId; |
|
247 | + $siteId = (int) $siteId; |
|
248 | 248 | } |
249 | 249 | $dest = UrlHelper::siteUrl($dest, null, null, $siteId); |
250 | 250 | } catch (\yii\base\Exception $e) { |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | if (Retour::$settings->preserveQueryString) { |
254 | 254 | $request = Craft::$app->getRequest(); |
255 | 255 | if (!empty($request->getQueryStringWithoutPath())) { |
256 | - $dest .= '?' . $request->getQueryStringWithoutPath(); |
|
256 | + $dest .= '?'.$request->getQueryStringWithoutPath(); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | $redirectMatchType = $redirect['redirectMatchType'] ?? 'notfound'; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | foreach ($redirects as $redirect) { |
435 | 435 | // Figure out what type of source matching to do |
436 | 436 | $redirectSrcMatch = $redirect['redirectSrcMatch'] ?? 'pathonly'; |
437 | - $redirectEnabled = (bool)$redirect['enabled']; |
|
437 | + $redirectEnabled = (bool) $redirect['enabled']; |
|
438 | 438 | if ($redirectEnabled === true) { |
439 | 439 | switch ($redirectSrcMatch) { |
440 | 440 | case 'pathonly': |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | if (preg_match($matchRegEx, $url) === 1) { |
481 | 481 | $this->incrementRedirectHitCount($redirect); |
482 | 482 | // If we're not associated with an EntryID, handle capture group replacement |
483 | - if ((int)$redirect['associatedElementId'] === 0) { |
|
483 | + if ((int) $redirect['associatedElementId'] === 0) { |
|
484 | 484 | $redirect['redirectDestUrl'] = preg_replace( |
485 | 485 | $matchRegEx, |
486 | 486 | $redirect['redirectDestUrl'], |
@@ -791,13 +791,13 @@ discard block |
||
791 | 791 | // Get the validated model attributes and save them to the db |
792 | 792 | $redirectConfig = $redirect->getAttributes(); |
793 | 793 | // 0 for a siteId needs to be converted to null |
794 | - if (empty($redirectConfig['siteId']) || (int)$redirectConfig['siteId'] === 0) { |
|
794 | + if (empty($redirectConfig['siteId']) || (int) $redirectConfig['siteId'] === 0) { |
|
795 | 795 | $redirectConfig['siteId'] = null; |
796 | 796 | } |
797 | 797 | // Throw an event to before saving the redirect |
798 | 798 | $db = Craft::$app->getDb(); |
799 | 799 | // See if a redirect exists with this source URL already |
800 | - if ((int)$redirectConfig['id'] === 0) { |
|
800 | + if ((int) $redirectConfig['id'] === 0) { |
|
801 | 801 | // Query the db table |
802 | 802 | $redirect = (new Query()) |
803 | 803 | ->from(['{{%retour_static_redirects}}']) |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | } |
812 | 812 | // Trigger a 'beforeSaveRedirect' event |
813 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
813 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
814 | 814 | $event = new RedirectEvent([ |
815 | 815 | 'isNew' => $isNew, |
816 | 816 | 'legacyUrl' => $redirectConfig['redirectSrcUrlParsed'], |
@@ -114,7 +114,7 @@ |
||
114 | 114 | } else { |
115 | 115 | $variables['sitesMenuLabel'] = Craft::t( |
116 | 116 | 'site', |
117 | - $sites->getSiteById((int)$variables['currentSiteId'])->name |
|
117 | + $sites->getSiteById((int) $variables['currentSiteId'])->name |
|
118 | 118 | ); |
119 | 119 | } |
120 | 120 | } else { |