Passed
Push — develop ( 4e4fdb...3d0a80 )
by Andrew
20:45 queued 11:55
created
src/helpers/UrlHelper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
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",
Please login to merge, or discard this patch.
src/controllers/ApiController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,6 +57,6 @@
 block discarded – undo
57 57
     {
58 58
         $redirects = Retour::$plugin->redirects->getAllStaticRedirects(null, $siteId);
59 59
 
60
-        return $this->asJson($redirects ?? []);
60
+        return $this->asJson($redirects ?? [ ]);
61 61
     }
62 62
 }
Please login to merge, or discard this patch.
src/models/Settings.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
178 178
      */
179 179
     public function behaviors()
180 180
     {
181
-        $craft31Behaviors = [];
181
+        $craft31Behaviors = [ ];
182 182
         if (Retour::$craft31) {
183 183
             $craft31Behaviors = [
184 184
                 'parser' => [
Please login to merge, or discard this patch.
src/controllers/TablesController.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $handled = 'all'
97 97
     ): Response {
98 98
         PermissionHelper::controllerPermissionCheck('retour:dashboard');
99
-        $data = [];
99
+        $data = [ ];
100 100
         $sortField = 'hitCount';
101 101
         $sortType = 'DESC';
102 102
         // Figure out the sorting type
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             }
109 109
         }
110 110
         $sortType = strtoupper($sortType);
111
-        $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];
111
+        $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];
112 112
         // Validate untrusted data
113 113
         if (!in_array($sortField, self::ALLOWED_STATS_SORT_FIELDS, true)) {
114 114
             throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.'));
@@ -116,35 +116,35 @@  discard block
 block discarded – undo
116 116
         // Query the db table
117 117
         $offset = ($page - 1) * $per_page;
118 118
         $query = (new Query())
119
-            ->from(['{{%retour_stats}}'])
119
+            ->from([ '{{%retour_stats}}' ])
120 120
             ->offset($offset)
121 121
             ->limit($per_page)
122
-            ->orderBy([$sortField => $sortType])
123
-            ->filterWhere(['like', 'redirectSrcUrl', $filter])
124
-            ->orFilterWhere(['like', 'referrerUrl', $filter])
122
+            ->orderBy([ $sortField => $sortType ])
123
+            ->filterWhere([ 'like', 'redirectSrcUrl', $filter ])
124
+            ->orFilterWhere([ 'like', 'referrerUrl', $filter ])
125 125
             ;
126
-        if ((int)$siteId !== 0) {
127
-            $query->andWhere(['siteId' => $siteId]);
126
+        if ((int) $siteId !== 0) {
127
+            $query->andWhere([ 'siteId' => $siteId ]);
128 128
         }
129 129
         if ($handled !== 'all') {
130
-            $query->andWhere(['handledByRetour' => self::HANDLED_MAP[$handled]]);
130
+            $query->andWhere([ 'handledByRetour' => self::HANDLED_MAP[ $handled ] ]);
131 131
         }
132 132
         $stats = $query->all();
133 133
         if ($stats) {
134 134
             // Add in the `addLink` field
135 135
             foreach ($stats as &$stat) {
136
-                $stat['addLink'] = '';
137
-                if (!$stat['handledByRetour']) {
138
-                    $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/'));
139
-                    $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [
136
+                $stat[ 'addLink' ] = '';
137
+                if (!$stat[ 'handledByRetour' ]) {
138
+                    $encodedUrl = urlencode('/' . ltrim($stat[ 'redirectSrcUrl' ], '/'));
139
+                    $stat[ 'addLink' ] = UrlHelper::cpUrl('retour/add-redirect', [
140 140
                         'defaultUrl' => $encodedUrl
141 141
                     ]);
142 142
                 }
143 143
             }
144 144
             // Format the data for the API
145
-            $data['data'] = $stats;
145
+            $data[ 'data' ] = $stats;
146 146
             $count = $query->count();
147
-            $data['links']['pagination'] = [
147
+            $data[ 'links' ][ 'pagination' ] = [
148 148
                 'total' => $count,
149 149
                 'per_page' => $per_page,
150 150
                 'current_page' => $page,
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         $siteId = 0
181 181
     ): Response {
182 182
         PermissionHelper::controllerPermissionCheck('retour:redirects');
183
-        $data = [];
183
+        $data = [ ];
184 184
         $sortField = 'hitCount';
185 185
         $sortType = 'DESC';
186 186
         // Figure out the sorting type
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             }
193 193
         }
194 194
         $sortType = strtoupper($sortType);
195
-        $sortType = self::SORT_MAP[$sortType] ?? self::SORT_MAP['DESC'];
195
+        $sortType = self::SORT_MAP[ $sortType ] ?? self::SORT_MAP[ 'DESC' ];
196 196
         // Validate untrusted data
197 197
         if (!in_array($sortField, self::ALLOWED_REDIRECTS_SORT_FIELDS, true)) {
198 198
             throw new BadRequestHttpException(Craft::t('retour', 'Invalid sort field specified.'));
@@ -200,42 +200,42 @@  discard block
 block discarded – undo
200 200
         // Query the db table
201 201
         $offset = ($page - 1) * $per_page;
202 202
         $query = (new Query())
203
-            ->from(['{{%retour_static_redirects}}'])
203
+            ->from([ '{{%retour_static_redirects}}' ])
204 204
             ->offset($offset)
205 205
             ->limit($per_page)
206
-            ->orderBy([$sortField => $sortType])
207
-            ->filterWhere(['like', 'redirectSrcUrl', $filter])
208
-            ->orFilterWhere(['like', 'redirectDestUrl', $filter])
206
+            ->orderBy([ $sortField => $sortType ])
207
+            ->filterWhere([ 'like', 'redirectSrcUrl', $filter ])
208
+            ->orFilterWhere([ 'like', 'redirectDestUrl', $filter ])
209 209
            ;
210
-        if ((int)$siteId !== 0) {
211
-            $query->andWhere(['siteId' => $siteId]);
210
+        if ((int) $siteId !== 0) {
211
+            $query->andWhere([ 'siteId' => $siteId ]);
212 212
         }
213 213
         $redirects = $query->all();
214 214
         // Add in the `deleteLink` field and clean up the redirects
215 215
         foreach ($redirects as &$redirect) {
216 216
             // Make sure the destination URL is not a regex
217
-            if ($redirect['redirectMatchType'] !== 'exactmatch') {
218
-                if (preg_match("/\$\d+/", $redirect['redirectDestUrl'])) {
219
-                    $redirect['redirectDestUrl'] = '';
217
+            if ($redirect[ 'redirectMatchType' ] !== 'exactmatch') {
218
+                if (preg_match("/\$\d+/", $redirect[ 'redirectDestUrl' ])) {
219
+                    $redirect[ 'redirectDestUrl' ] = '';
220 220
                 }
221 221
             }
222 222
             // Handle extracting the site name
223
-            $redirect['siteName'] = Craft::t('retour', 'All Sites');
224
-            if ($redirect['siteId']) {
223
+            $redirect[ 'siteName' ] = Craft::t('retour', 'All Sites');
224
+            if ($redirect[ 'siteId' ]) {
225 225
                 $sites = Craft::$app->getSites();
226
-                $site = $sites->getSiteById($redirect['siteId']);
226
+                $site = $sites->getSiteById($redirect[ 'siteId' ]);
227 227
                 if ($site) {
228
-                    $redirect['siteName'] = $site->name;
228
+                    $redirect[ 'siteName' ] = $site->name;
229 229
                 }
230 230
             }
231 231
 
232
-            $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']);
232
+            $redirect[ 'editLink' ] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect[ 'id' ]);
233 233
         }
234 234
         // Format the data for the API
235 235
         if ($redirects) {
236
-            $data['data'] = $redirects;
236
+            $data[ 'data' ] = $redirects;
237 237
             $count = $query->count();
238
-            $data['links']['pagination'] = [
238
+            $data[ 'links' ][ 'pagination' ] = [
239 239
                 'total' => $count,
240 240
                 'per_page' => $per_page,
241 241
                 'current_page' => $page,
Please login to merge, or discard this patch.
src/controllers/RedirectsController.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     // Protected Properties
42 42
     // =========================================================================
43 43
 
44
-    protected $allowAnonymous = [];
44
+    protected $allowAnonymous = [ ];
45 45
 
46 46
     // Public Methods
47 47
     // =========================================================================
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function actionRedirects(string $siteHandle = null): Response
59 59
     {
60
-        $variables = [];
60
+        $variables = [ ];
61 61
         PermissionHelper::controllerPermissionCheck('retour:redirects');
62 62
         // Get the site to edit
63 63
         $siteId = MultiSiteHelper::getSiteIdFromHandle($siteHandle);
@@ -70,32 +70,32 @@  discard block
 block discarded – undo
70 70
         } catch (InvalidConfigException $e) {
71 71
             Craft::error($e->getMessage(), __METHOD__);
72 72
         }
73
-        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
73
+        $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(
74 74
             '@nystudio107/retour/assetbundles/retour/dist',
75 75
             true
76 76
         );
77 77
         // Enabled sites
78 78
         MultiSiteHelper::setMultiSiteVariables($siteHandle, $siteId, $variables);
79
-        $variables['controllerHandle'] = 'redirects';
79
+        $variables[ 'controllerHandle' ] = 'redirects';
80 80
 
81 81
         // Basic variables
82
-        $variables['fullPageForm'] = false;
83
-        $variables['docsUrl'] = self::DOCUMENTATION_URL;
84
-        $variables['pluginName'] = $pluginName;
85
-        $variables['title'] = $templateTitle;
86
-        $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : '';
87
-        $variables['crumbs'] = [
82
+        $variables[ 'fullPageForm' ] = false;
83
+        $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;
84
+        $variables[ 'pluginName' ] = $pluginName;
85
+        $variables[ 'title' ] = $templateTitle;
86
+        $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : '';
87
+        $variables[ 'crumbs' ] = [
88 88
             [
89 89
                 'label' => $pluginName,
90 90
                 'url' => UrlHelper::cpUrl('retour'),
91 91
             ],
92 92
             [
93 93
                 'label' => $templateTitle,
94
-                'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri),
94
+                'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri),
95 95
             ],
96 96
         ];
97
-        $variables['docTitle'] = "{$pluginName} - {$templateTitle}";
98
-        $variables['selectedSubnavItem'] = 'redirects';
97
+        $variables[ 'docTitle' ] = "{$pluginName} - {$templateTitle}";
98
+        $variables[ 'selectedSubnavItem' ] = 'redirects';
99 99
 
100 100
         // Render the template
101 101
         return $this->renderTemplate('retour/redirects/index', $variables);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         int $siteId = 0,
120 120
         StaticRedirectsModel $redirect = null
121 121
     ): Response {
122
-        $variables = [];
122
+        $variables = [ ];
123 123
         PermissionHelper::controllerPermissionCheck('retour:redirects');
124 124
 
125 125
         // Load in the redirect
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
         if ($redirect === null) {
134 134
             $redirectConfig = Retour::$plugin->redirects->getRedirectById($redirectId);
135 135
             if ($redirectConfig === null) {
136
-                $redirectConfig = [];
136
+                $redirectConfig = [ ];
137 137
                 Craft::error(
138 138
                     Craft::t(
139 139
                         'retour',
140 140
                         "Couldn't load redirect id {id}",
141
-                        ['id' => $redirectId]
141
+                        [ 'id' => $redirectId ]
142 142
                     ),
143 143
                     __METHOD__
144 144
                 );
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
         if ($redirect->siteId) {
152 152
             $site = $sites->getSiteById($redirect->siteId);
153 153
             if ($site) {
154
-                MultiSiteHelper::requirePermission('editSite:'.$site->uid);
154
+                MultiSiteHelper::requirePermission('editSite:' . $site->uid);
155 155
             }
156 156
         }
157 157
         if ($siteId) {
158 158
             $site = $sites->getSiteById($siteId);
159 159
             if ($site) {
160
-                MultiSiteHelper::requirePermission('editSite:'.$site->uid);
160
+                MultiSiteHelper::requirePermission('editSite:' . $site->uid);
161 161
             }
162 162
         }
163 163
         $pluginName = Retour::$settings->pluginName;
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
         } catch (InvalidConfigException $e) {
170 170
             Craft::error($e->getMessage(), __METHOD__);
171 171
         }
172
-        $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl(
172
+        $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl(
173 173
             '@nystudio107/retour/assetbundles/retour/dist',
174 174
             true
175 175
         );
176 176
         // Sites menu
177 177
         MultiSiteHelper::setSitesMenuVariables($variables);
178
-        $variables['controllerHandle'] = 'redirects';
178
+        $variables[ 'controllerHandle' ] = 'redirects';
179 179
 
180 180
         // Basic variables
181
-        $variables['fullPageForm'] = true;
182
-        $variables['docsUrl'] = self::DOCUMENTATION_URL;
183
-        $variables['pluginName'] = $pluginName;
184
-        $variables['title'] = $templateTitle;
185
-        $variables['crumbs'] = [
181
+        $variables[ 'fullPageForm' ] = true;
182
+        $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL;
183
+        $variables[ 'pluginName' ] = $pluginName;
184
+        $variables[ 'title' ] = $templateTitle;
185
+        $variables[ 'crumbs' ] = [
186 186
             [
187 187
                 'label' => $pluginName,
188 188
                 'url' => UrlHelper::cpUrl('retour'),
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
             ],
194 194
             [
195 195
                 'label' => $templateTitle,
196
-                'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId),
196
+                'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId),
197 197
             ],
198 198
         ];
199
-        $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}";
200
-        $variables['selectedSubnavItem'] = 'redirects';
201
-        $variables['redirect'] = $redirect;
199
+        $variables[ 'docTitle' ] = "{$pluginName} - Redirects - {$templateTitle}";
200
+        $variables[ 'selectedSubnavItem' ] = 'redirects';
201
+        $variables[ 'redirect' ] = $redirect;
202 202
 
203 203
         // Render the template
204 204
         return $this->renderTemplate('retour/redirects/_edit', $variables);
@@ -251,17 +251,17 @@  discard block
 block discarded – undo
251 251
         if ($redirectConfig === null) {
252 252
             throw new NotFoundHttpException('Redirect not found');
253 253
         }
254
-        $redirectConfig['id'] = (int)$redirectConfig['id'];
254
+        $redirectConfig[ 'id' ] = (int) $redirectConfig[ 'id' ];
255 255
         // Handle enforcing trailing slashes
256 256
         $generalConfig = Craft::$app->getConfig()->getGeneral();
257
-        if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') {
258
-            $destUrl = $redirectConfig['redirectDestUrl'] ?? '';
259
-            $redirectConfig['redirectDestUrl'] = $this->addSlashToSiteUrls($destUrl);
257
+        if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig[ 'redirectMatchType' ] === 'exactmatch') {
258
+            $destUrl = $redirectConfig[ 'redirectDestUrl' ] ?? '';
259
+            $redirectConfig[ 'redirectDestUrl' ] = $this->addSlashToSiteUrls($destUrl);
260 260
         }
261 261
         // Handle URL encoded URLs by decoding them before saving them
262
-        if ($redirectConfig['redirectMatchType'] === 'exactmatch') {
263
-            $redirectConfig['redirectSrcUrl'] = urldecode($redirectConfig['redirectSrcUrl'] ?? '');
264
-            $redirectConfig['redirectSrcUrlParsed'] = urldecode($redirectConfig['redirectSrcUrlParsed'] ?? '');
262
+        if ($redirectConfig[ 'redirectMatchType' ] === 'exactmatch') {
263
+            $redirectConfig[ 'redirectSrcUrl' ] = urldecode($redirectConfig[ 'redirectSrcUrl' ] ?? '');
264
+            $redirectConfig[ 'redirectSrcUrlParsed' ] = urldecode($redirectConfig[ 'redirectSrcUrlParsed' ] ?? '');
265 265
         }
266 266
         $redirect = new StaticRedirectsModel($redirectConfig);
267 267
         // Make sure the redirect validates
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
         Retour::$plugin->redirects->saveRedirect($redirectConfig);
280 280
         // Handle the case where the redirect wasn't saved because it'd create a redirect loop
281 281
         $testRedirectConfig = Retour::$plugin->redirects->getRedirectByRedirectSrcUrl(
282
-            $redirectConfig['redirectSrcUrl'],
283
-            $redirectConfig['siteId']
282
+            $redirectConfig[ 'redirectSrcUrl' ],
283
+            $redirectConfig[ 'siteId' ]
284 284
         );
285 285
         if ($testRedirectConfig === null) {
286 286
             Craft::$app->getSession()->setError(Craft::t('app', "Couldn't save redirect settings because it'd create a redirect loop."));
Please login to merge, or discard this patch.
src/migrations/m210603_221000_add_gql_schema_components.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,10 +20,10 @@
 block discarded – undo
20 20
         $schemaVersion = $projectConfig->get('plugins.retour.schemaVersion', true);
21 21
 
22 22
         if (version_compare($schemaVersion, '3.0.10', '<')) {
23
-            foreach ($projectConfig->get('graphql.schemas') ?? [] as $schemaUid => $schemaComponents) {
24
-                if (isset($schemaComponents['scope'])) {
25
-                    $scope = $schemaComponents['scope'];
26
-                    $scope[] = 'retour.all:read';
23
+            foreach ($projectConfig->get('graphql.schemas') ?? [ ] as $schemaUid => $schemaComponents) {
24
+                if (isset($schemaComponents[ 'scope' ])) {
25
+                    $scope = $schemaComponents[ 'scope' ];
26
+                    $scope[ ] = 'retour.all:read';
27 27
 
28 28
                     $projectConfig->set("graphql.schemas.$schemaUid.scope", $scope);
29 29
                 }
Please login to merge, or discard this patch.
src/helpers/Gql.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,6 +17,6 @@
 block discarded – undo
17 17
     {
18 18
         $allowedEntities = self::extractAllowedEntitiesFromSchema();
19 19
 
20
-        return isset($allowedEntities['retour']);
20
+        return isset($allowedEntities[ 'retour' ]);
21 21
     }
22 22
 }
Please login to merge, or discard this patch.
src/gql/queries/RetourQuery.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
     public static function getQueries($checkToken = true): array
35 35
     {
36 36
         if ($checkToken && !GqlHelper::canQueryRetour()) {
37
-            return [];
37
+            return [ ];
38 38
         }
39 39
 
40 40
         return [
Please login to merge, or discard this patch.
src/Retour.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * @inheritdoc
127 127
      */
128
-    public function __construct($id, $parent = null, array $config = [])
128
+    public function __construct($id, $parent = null, array $config = [ ])
129 129
     {
130
-        $config['components'] = [
130
+        $config[ 'components' ] = [
131 131
             'redirects' => Redirects::class,
132 132
             'statistics' => Statistics::class,
133 133
             // Register the manifest service
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     /**
164 164
      * @var array The URIs for the element before it was saved
165 165
      */
166
-    public $oldElementUris = [];
166
+    public $oldElementUris = [ ];
167 167
 
168 168
     // Public Methods
169 169
     // =========================================================================
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             Craft::t(
198 198
                 'retour',
199 199
                 '{name} plugin loaded',
200
-                ['name' => $this->name]
200
+                [ 'name' => $this->name ]
201 201
             ),
202 202
             __METHOD__
203 203
         );
@@ -217,18 +217,18 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function getCpNavItem()
219 219
     {
220
-        $subNavs = [];
220
+        $subNavs = [ ];
221 221
         $navItem = parent::getCpNavItem();
222 222
         $currentUser = Craft::$app->getUser()->getIdentity();
223 223
         // Only show sub-navs the user has permission to view
224 224
         if ($currentUser->can('retour:dashboard')) {
225
-            $subNavs['dashboard'] = [
225
+            $subNavs[ 'dashboard' ] = [
226 226
                 'label' => 'Dashboard',
227 227
                 'url' => 'retour/dashboard',
228 228
             ];
229 229
         }
230 230
         if ($currentUser->can('retour:redirects')) {
231
-            $subNavs['redirects'] = [
231
+            $subNavs[ 'redirects' ] = [
232 232
                 'label' => 'Redirects',
233 233
                 'url' => 'retour/redirects',
234 234
             ];
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             $editableSettings = false;
240 240
         }
241 241
         if ($currentUser->can('retour:settings') && $editableSettings) {
242
-            $subNavs['settings'] = [
242
+            $subNavs[ 'settings' ] = [
243 243
                 'label' => 'Settings',
244 244
                 'url' => 'retour/settings',
245 245
             ];
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         }
251 251
         // A single sub nav item is redundant
252 252
         if (count($subNavs) === 1) {
253
-            $subNavs = [];
253
+            $subNavs = [ ];
254 254
         }
255 255
         $navItem = array_merge($navItem, [
256 256
             'subnav' => $subNavs,
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
         Event::on(
307 307
             ClearCaches::class,
308 308
             ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
309
-            function (RegisterCacheOptionsEvent $event) {
309
+            function(RegisterCacheOptionsEvent $event) {
310 310
                 Craft::debug(
311 311
                     'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
312 312
                     __METHOD__
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         Event::on(
323 323
             Plugins::class,
324 324
             Plugins::EVENT_AFTER_INSTALL_PLUGIN,
325
-            function (PluginEvent $event) {
325
+            function(PluginEvent $event) {
326 326
                 if ($event->plugin === $this) {
327 327
                     // Invalidate our caches after we've been installed
328 328
                     $this->clearAllCaches();
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         Event::on(
350 350
             CraftVariable::class,
351 351
             CraftVariable::EVENT_INIT,
352
-            function (Event $event) {
352
+            function(Event $event) {
353 353
                 /** @var CraftVariable $variable */
354 354
                 $variable = $event->sender;
355 355
                 $variable->set('retour', [
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
         Event::on(
363 363
             Elements::class,
364 364
             Elements::EVENT_BEFORE_SAVE_ELEMENT,
365
-            function (ElementEvent $event) {
365
+            function(ElementEvent $event) {
366 366
                 Craft::debug(
367 367
                     'Elements::EVENT_BEFORE_SAVE_ELEMENT',
368 368
                     __METHOD__
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
                         if (strpos($element->uri, '__temp_') === false && !$element->propagating) {
386 386
                             // Stash the old URLs by element id, and do so only once,
387 387
                             // in case we are called more than once per request
388
-                            if (empty($this->oldElementUris[$element->id])) {
389
-                                $this->oldElementUris[$element->id] = $this->getAllElementUris($element);
388
+                            if (empty($this->oldElementUris[ $element->id ])) {
389
+                                $this->oldElementUris[ $element->id ] = $this->getAllElementUris($element);
390 390
                             }
391 391
                         }
392 392
                     }
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
         Event::on(
398 398
             Elements::class,
399 399
             Elements::EVENT_AFTER_SAVE_ELEMENT,
400
-            function (ElementEvent $event) {
400
+            function(ElementEvent $event) {
401 401
                 Craft::debug(
402 402
                     'Elements::EVENT_AFTER_SAVE_ELEMENT',
403 403
                     __METHOD__
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
         Event::on(
420 420
             Plugins::class,
421 421
             Plugins::EVENT_AFTER_LOAD_PLUGINS,
422
-            function () {
422
+            function() {
423 423
                 // Install these only after all other plugins have loaded
424 424
                 $request = Craft::$app->getRequest();
425 425
                 // Only respond to non-console site requests
@@ -437,26 +437,26 @@  discard block
 block discarded – undo
437 437
             Event::on(
438 438
                 Gql::class,
439 439
                 Gql::EVENT_REGISTER_GQL_TYPES,
440
-                function (RegisterGqlTypesEvent $event) {
440
+                function(RegisterGqlTypesEvent $event) {
441 441
                     Craft::debug(
442 442
                         'Gql::EVENT_REGISTER_GQL_TYPES',
443 443
                         __METHOD__
444 444
                     );
445
-                    $event->types[] = RetourInterface::class;
445
+                    $event->types[ ] = RetourInterface::class;
446 446
                 }
447 447
             );
448 448
             // Handler: Gql::EVENT_REGISTER_GQL_QUERIES
449 449
             Event::on(
450 450
                 Gql::class,
451 451
                 Gql::EVENT_REGISTER_GQL_QUERIES,
452
-                function (RegisterGqlQueriesEvent $event) {
452
+                function(RegisterGqlQueriesEvent $event) {
453 453
                     Craft::debug(
454 454
                         'Gql::EVENT_REGISTER_GQL_QUERIES',
455 455
                         __METHOD__
456 456
                     );
457 457
                     $queries = RetourQuery::getQueries();
458 458
                     foreach ($queries as $key => $value) {
459
-                        $event->queries[$key] = $value;
459
+                        $event->queries[ $key ] = $value;
460 460
                     }
461 461
                 }
462 462
             );
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
                 Event::on(
466 466
                     Gql::class,
467 467
                     Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS,
468
-                    function (RegisterGqlSchemaComponentsEvent $event) {
468
+                    function(RegisterGqlSchemaComponentsEvent $event) {
469 469
                         Craft::debug(
470 470
                             'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS',
471 471
                             __METHOD__
472 472
                         );
473 473
                         $label = Craft::t('retour', 'Retour');
474
-                        $event->queries[$label]['retour.all:read'] = ['label' => Craft::t('retour', 'Query Retour data')];
474
+                        $event->queries[ $label ][ 'retour.all:read' ] = [ 'label' => Craft::t('retour', 'Query Retour data') ];
475 475
                     }
476 476
                 );
477 477
             }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
             Event::on(
482 482
                 Schema::class,
483 483
                 AlterSchemaFields::EVENT,
484
-                [GetCraftQLSchema::class, 'handle']
484
+                [ GetCraftQLSchema::class, 'handle' ]
485 485
             );
486 486
         }
487 487
     }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         Event::on(
496 496
             UrlManager::class,
497 497
             UrlManager::EVENT_REGISTER_SITE_URL_RULES,
498
-            function (RegisterUrlRulesEvent $event) {
498
+            function(RegisterUrlRulesEvent $event) {
499 499
                 Craft::debug(
500 500
                     'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
501 501
                     __METHOD__
@@ -518,15 +518,15 @@  discard block
 block discarded – undo
518 518
         Event::on(
519 519
             Dashboard::class,
520 520
             Dashboard::EVENT_REGISTER_WIDGET_TYPES,
521
-            function (RegisterComponentTypesEvent $event) {
522
-                $event->types[] = RetourWidget::class;
521
+            function(RegisterComponentTypesEvent $event) {
522
+                $event->types[ ] = RetourWidget::class;
523 523
             }
524 524
         );
525 525
         // Handler: UrlManager::EVENT_REGISTER_CP_URL_RULES
526 526
         Event::on(
527 527
             UrlManager::class,
528 528
             UrlManager::EVENT_REGISTER_CP_URL_RULES,
529
-            function (RegisterUrlRulesEvent $event) {
529
+            function(RegisterUrlRulesEvent $event) {
530 530
                 Craft::debug(
531 531
                     'UrlManager::EVENT_REGISTER_CP_URL_RULES',
532 532
                     __METHOD__
@@ -542,13 +542,13 @@  discard block
 block discarded – undo
542 542
         Event::on(
543 543
             UserPermissions::class,
544 544
             UserPermissions::EVENT_REGISTER_PERMISSIONS,
545
-            function (RegisterUserPermissionsEvent $event) {
545
+            function(RegisterUserPermissionsEvent $event) {
546 546
                 Craft::debug(
547 547
                     'UserPermissions::EVENT_REGISTER_PERMISSIONS',
548 548
                     __METHOD__
549 549
                 );
550 550
                 // Register our custom permissions
551
-                $event->permissions[Craft::t('retour', 'Retour')] = $this->customAdminCpPermissions();
551
+                $event->permissions[ Craft::t('retour', 'Retour') ] = $this->customAdminCpPermissions();
552 552
             }
553 553
         );
554 554
     }
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
         Event::on(
565 565
             ErrorHandler::class,
566 566
             ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
567
-            function (ExceptionEvent $event) {
567
+            function(ExceptionEvent $event) {
568 568
                 Craft::debug(
569 569
                     'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
570 570
                     __METHOD__
@@ -607,16 +607,16 @@  discard block
 block discarded – undo
607 607
     protected function handleElementUriChange(Element $element)
608 608
     {
609 609
         $uris = $this->getAllElementUris($element);
610
-        if (!empty($this->oldElementUris[$element->id])) {
611
-            $oldElementUris = $this->oldElementUris[$element->id];
610
+        if (!empty($this->oldElementUris[ $element->id ])) {
611
+            $oldElementUris = $this->oldElementUris[ $element->id ];
612 612
             foreach ($uris as $siteId => $newUri) {
613
-                if (!empty($oldElementUris[$siteId])) {
614
-                    $oldUri = $oldElementUris[$siteId];
613
+                if (!empty($oldElementUris[ $siteId ])) {
614
+                    $oldUri = $oldElementUris[ $siteId ];
615 615
                     Craft::debug(
616 616
                         Craft::t(
617 617
                             'retour',
618 618
                             'Comparing old: {oldUri} to new: {newUri}',
619
-                            ['oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true)]
619
+                            [ 'oldUri' => print_r($oldUri, true), 'newUri' => print_r($newUri, true) ]
620 620
                         ),
621 621
                         __METHOD__
622 622
                     );
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
                         if (self::$settings->uriChangeRedirectSrcMatch === 'fullurl') {
637 637
                             try {
638 638
                                 if ($redirectSiteId !== null) {
639
-                                    $redirectSiteId = (int)$redirectSiteId;
639
+                                    $redirectSiteId = (int) $redirectSiteId;
640 640
                                 }
641 641
                                 $oldUri = UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId);
642 642
                                 $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId);
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
      */
670 670
     protected function getAllElementUris(Element $element): array
671 671
     {
672
-        $uris = [];
672
+        $uris = [ ];
673 673
         if (!self::$craft32 || !ElementHelper::isDraftOrRevision($element)) {
674 674
             $sites = Craft::$app->getSites()->getAllSites();
675 675
             foreach ($sites as $site) {
676 676
                 $uri = Craft::$app->getElements()->getElementUriForSite($element->id, $site->id);
677 677
                 if ($uri !== null) {
678
-                    $uris[$site->id] = $uri;
678
+                    $uris[ $site->id ] = $uri;
679 679
                 }
680 680
             }
681 681
         }
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
             Craft::t(
685 685
                 'retour',
686 686
                 'Getting Element URIs: {uris}',
687
-                ['uris' => print_r($uris, true)]
687
+                [ 'uris' => print_r($uris, true) ]
688 688
             ),
689 689
             __METHOD__
690 690
         );
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
             [
740 740
                 'key' => 'retour-redirect-caches',
741 741
                 'label' => Craft::t('retour', 'Retour redirect caches'),
742
-                'action' => [self::$plugin->redirects, 'invalidateCaches'],
742
+                'action' => [ self::$plugin->redirects, 'invalidateCaches' ],
743 743
             ],
744 744
         ];
745 745
     }
Please login to merge, or discard this patch.