Passed
Push — develop ( f22103...8a1456 )
by Andrew
21:06
created
src/migrations/m190416_212500_widget_type_update.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         // Update retour widget type
21 21
         $this->update('{{%widgets}}', [
22 22
             'type' => RetourWidget::class
23
-        ], ['type' => 'Retour']);
23
+        ], [ 'type' => 'Retour' ]);
24 24
 
25 25
         return true;
26 26
     }
Please login to merge, or discard this patch.
src/migrations/Install.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         // Update retour widget type
21 21
         $this->update('{{%widgets}}', [
22 22
             'type' => RetourWidget::class
23
-        ], ['type' => 'Retour']);
23
+        ], [ 'type' => 'Retour' ]);
24 24
 
25 25
         return true;
26 26
     }
Please login to merge, or discard this patch.
src/services/Statistics.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         }
61 61
         // Query the db table
62 62
         $stats = (new Query())
63
-            ->from(['{{%retour_stats}}'])
63
+            ->from([ '{{%retour_stats}}' ])
64 64
             ->orderBy('hitCount DESC')
65 65
             ->limit(Retour::$settings->statsDisplayLimit)
66 66
             ->all();
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
     public function getRecentStatistics($days = 1, $handled = false): array
80 80
     {
81 81
         // Ensure is an int
82
-        $handledInt = (int)$handled;
83
-        $stats = [];
82
+        $handledInt = (int) $handled;
83
+        $stats = [ ];
84 84
         $db = Craft::$app->getDb();
85 85
         if ($db->getIsMysql()) {
86 86
             // Query the db table
87 87
             $stats = (new Query())
88
-                ->from(['{{%retour_stats}}'])
88
+                ->from([ '{{%retour_stats}}' ])
89 89
                 ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )")
90 90
                 ->andWhere("handledByRetour = {$handledInt}")
91 91
                 ->orderBy('hitLastTime DESC')
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
         if ($db->getIsPgsql()) {
95 95
             // Query the db table
96 96
             $stats = (new Query())
97
-                ->from(['{{%retour_stats}}'])
97
+                ->from([ '{{%retour_stats}}' ])
98 98
                 ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )")
99
-                ->andWhere(['handledByRetour' => $handledInt])
99
+                ->andWhere([ 'handledByRetour' => $handledInt ])
100 100
                 ->orderBy('hitLastTime DESC')
101 101
                 ->all();
102 102
         }
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
         $stats->validate();
164 164
         // Find any existing retour_stats record
165 165
         $statsConfig = (new Query())
166
-            ->from(['{{%retour_stats}}'])
167
-            ->where(['redirectSrcUrl' => $stats->redirectSrcUrl])
166
+            ->from([ '{{%retour_stats}}' ])
167
+            ->where([ 'redirectSrcUrl' => $stats->redirectSrcUrl ])
168 168
             ->one();
169 169
         // If no record is found, initialize some values
170 170
         if ($statsConfig === null) {
171 171
             $stats->id = 0;
172 172
             $stats->hitCount = 0;
173 173
         } else {
174
-            $stats->id = $statsConfig['id'];
175
-            $stats->hitCount = $statsConfig['hitCount'];
174
+            $stats->id = $statsConfig[ 'id' ];
175
+            $stats->hitCount = $statsConfig[ 'hitCount' ];
176 176
         }
177 177
         // Merge in the updated info
178 178
         $stats->siteId = $siteId;
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
         $stats->userAgent = $userAgent;
182 182
         $stats->exceptionMessage = $exceptionMessage;
183 183
         $stats->exceptionFilePath = $exceptionFilePath;
184
-        $stats->exceptionFileLine = (int)$exceptionFileLine;
184
+        $stats->exceptionFileLine = (int) $exceptionFileLine;
185 185
         $stats->hitLastTime = Db::prepareDateForDb(new \DateTime());
186
-        $stats->handledByRetour = (int)$handled;
186
+        $stats->handledByRetour = (int) $handled;
187 187
         $stats->hitCount++;
188 188
         $statsConfig = $stats->getAttributes();
189 189
         // Record the updated statistics
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                 Craft::t(
254 254
                     'retour',
255 255
                     'Trimmed {rows} from retour_stats table',
256
-                    ['rows' => $affectedRows]
256
+                    [ 'rows' => $affectedRows ]
257 257
                 ),
258 258
                 __METHOD__
259 259
             );
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                 Craft::t(
275 275
                     'retour',
276 276
                     'Error validating statistics {id}: {errors}',
277
-                    ['id' => $stats->id, 'errors' => print_r($stats->getErrors(), true)]
277
+                    [ 'id' => $stats->id, 'errors' => print_r($stats->getErrors(), true) ]
278 278
                 ),
279 279
                 __METHOD__
280 280
             );
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
         // Get the validated model attributes and save them to the db
285 285
         $statsConfig = $stats->getAttributes();
286 286
         $db = Craft::$app->getDb();
287
-        if ($statsConfig['id'] !== 0) {
287
+        if ($statsConfig[ 'id' ] !== 0) {
288 288
             // Update the existing record
289 289
             try {
290 290
                 $result = $db->createCommand()->update(
291 291
                     '{{%retour_stats}}',
292 292
                     $statsConfig,
293 293
                     [
294
-                        'id' => $statsConfig['id'],
294
+                        'id' => $statsConfig[ 'id' ],
295 295
                     ]
296 296
                 )->execute();
297 297
             } catch (Exception $e) {
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                 // Craft::error($e->getMessage(), __METHOD__);
301 301
             }
302 302
         } else {
303
-            unset($statsConfig['id']);
303
+            unset($statsConfig[ 'id' ]);
304 304
             // Create a new record
305 305
             try {
306 306
                 $db->createCommand()->insert(
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         $now = round(microtime(true) * 1000);
328 328
         $cache = Craft::$app->getCache();
329 329
         $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY);
330
-        if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) {
330
+        if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) {
331 331
             $limited = true;
332 332
         }
333 333
         $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0);
Please login to merge, or discard this patch.
src/listeners/GetCraftQLSchema.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -62,36 +62,36 @@  discard block
 block discarded – undo
62 62
                 // Boolean field
63 63
                 $retourField
64 64
                     ->addBooleanField($field)
65
-                    ->resolve(function ($redirect) use ($field) {
66
-                        $result = $redirect[$field] ?? null;
67
-                        return $result === null ? $result : (bool)$result;
65
+                    ->resolve(function($redirect) use ($field) {
66
+                        $result = $redirect[ $field ] ?? null;
67
+                        return $result === null ? $result : (bool) $result;
68 68
                     });
69 69
             } elseif (in_array($field, self::INT_FIELDS, true)) {
70 70
                 // Integer field
71 71
                 $retourField
72 72
                     ->addIntField($field)
73
-                    ->resolve(function ($redirect) use ($field) {
74
-                        $result = $redirect[$field] ?? null;
75
-                        return $result === null ? $result : (int)$result;
73
+                    ->resolve(function($redirect) use ($field) {
74
+                        $result = $redirect[ $field ] ?? null;
75
+                        return $result === null ? $result : (int) $result;
76 76
                     });
77 77
             } else {
78 78
                 // String field
79 79
                 $retourField
80 80
                     ->addStringField($field)
81
-                    ->resolve(function ($redirect) use ($field) {
82
-                        $result = $redirect[$field] ?? null;
83
-                        return $result === null ? $result : (string)$result;
81
+                    ->resolve(function($redirect) use ($field) {
82
+                        $result = $redirect[ $field ] ?? null;
83
+                        return $result === null ? $result : (string) $result;
84 84
                     });
85 85
             }
86 86
         }
87 87
         // Add the root
88 88
         $event->schema->addField('retour')
89
-            ->arguments(function (FieldBuilder $field) {
89
+            ->arguments(function(FieldBuilder $field) {
90 90
                 $field->addStringArgument('uri');
91 91
                 $field->addIntArgument('siteId');
92 92
             })
93 93
             ->type($retourField)
94
-            ->resolve(function ($root, $args, $context, $info) {
94
+            ->resolve(function($root, $args, $context, $info) {
95 95
                 // If our root is an Element, extract the URI and siteId from it
96 96
                 if ($root instanceof Element) {
97 97
                     /** Element $root */
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
                     $siteId = $root->siteId;
100 100
                 } else {
101 101
                     // Otherwise use the passed in arguments, or defaults
102
-                    $uri = $args['uri'] ?? '/';
103
-                    $siteId = $args['siteId'] ?? null;
102
+                    $uri = $args[ 'uri' ] ?? '/';
103
+                    $siteId = $args[ 'siteId' ] ?? null;
104 104
                 }
105 105
                 $uri = trim($uri === '/' ? '__home__' : $uri);
106 106
 
Please login to merge, or discard this patch.
src/gql/interfaces/RetourInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,9 +48,9 @@
 block discarded – undo
48 48
 
49 49
         $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([
50 50
             'name' => static::getName(),
51
-            'fields' => self::class.'::getFieldDefinitions',
51
+            'fields' => self::class . '::getFieldDefinitions',
52 52
             'description' => 'This is the interface implemented by Retour.',
53
-            'resolveType' => function (array $value) {
53
+            'resolveType' => function(array $value) {
54 54
                 return GqlEntityRegistry::getEntity(RetourGenerator::getName());
55 55
             },
56 56
         ]));
Please login to merge, or discard this patch.
src/gql/types/generators/RetourGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,24 +34,24 @@
 block discarded – undo
34 34
      */
35 35
     public static function generateTypes($context = null): array
36 36
     {
37
-        $gqlTypes = [];
37
+        $gqlTypes = [ ];
38 38
         $retourFields = RetourInterface::getFieldDefinitions();
39 39
         $retourArgs = RetourArguments::getArguments();
40 40
         $typeName = self::getName();
41 41
         $retourType = GqlEntityRegistry::getEntity($typeName)
42 42
             ?: GqlEntityRegistry::createEntity($typeName, new RetourType([
43 43
                 'name' => $typeName,
44
-                'args' => function () use ($retourArgs) {
44
+                'args' => function() use ($retourArgs) {
45 45
                     return $retourArgs;
46 46
                 },
47
-                'fields' => function () use ($retourFields) {
47
+                'fields' => function() use ($retourFields) {
48 48
                     return $retourFields;
49 49
                 },
50 50
                 'description' => 'This entity has all the Retour fields',
51 51
             ]));
52 52
 
53
-        $gqlTypes[$typeName] = $retourType;
54
-        TypeLoader::registerType($typeName, function () use ($retourType) {
53
+        $gqlTypes[ $typeName ] = $retourType;
54
+        TypeLoader::registerType($typeName, function() use ($retourType) {
55 55
             return $retourType;
56 56
         });
57 57
 
Please login to merge, or discard this patch.
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.