Completed
Pull Request — master (#184)
by Matthew
05:19
created
src/Xtools/ArticleInfoRepository.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $datesConditions = $this->getDateConditions($start, $end);
30 30
 
31 31
         $sql = "SELECT COUNT(DISTINCT(rev_id)) AS count, rev_user_text AS username, ug_group AS current
32
-                FROM " . $project->getTableName('revision') . "
32
+                FROM " . $project->getTableName('revision')."
33 33
                 LEFT JOIN $userGroupsTable ON rev_user = ug_user
34 34
                 LEFT JOIN $userFormerGroupsTable ON rev_user = ufg_user
35 35
                 WHERE rev_page = :pageId AND (ug_group = 'bot' OR ufg_group = 'bot') $datesConditions
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
         $sql = "SELECT log_action, log_type, log_timestamp AS 'timestamp'
58 58
                 FROM $loggingTable
59
-                WHERE log_namespace = '" . $page->getNamespace() . "'
59
+                WHERE log_namespace = '".$page->getNamespace()."'
60 60
                 AND log_title = :title AND log_timestamp > 1 $datesConditions
61 61
                 AND log_type IN ('delete', 'move', 'protect', 'stable')";
62 62
         $title = str_replace(' ', '_', $page->getTitle());
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
         $projectLang = $page->getProject()->getLang();
81 81
 
82
-        $url = "https://api.wikiwho.net/$projectLang/api/v1.0.0-beta/rev_content/" .
82
+        $url = "https://api.wikiwho.net/$projectLang/api/v1.0.0-beta/rev_content/".
83 83
             "$title/?o_rev_id=false&editor=true&token_id=false&out=false&in=false";
84 84
 
85 85
         $res = $client->request('GET', $url, ['http_errors' => false]);
Please login to merge, or discard this patch.
src/AppBundle/Controller/EditCounterController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@
 block discarded – undo
135 135
         }
136 136
 
137 137
         $ret = [
138
-            'xtTitle' => $this->user->getUsername() . ' - ' . $this->project->getTitle(),
138
+            'xtTitle' => $this->user->getUsername().' - '.$this->project->getTitle(),
139 139
             'xtPage' => 'ec',
140 140
             'user' => $this->user,
141 141
             'project' => $this->project,
Please login to merge, or discard this patch.
src/Xtools/Project.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function getUrl($withTrailingSlash = true)
129 129
     {
130
-        return rtrim($this->getBasicInfo()['url'], '/') . ($withTrailingSlash ? '/' : '');
130
+        return rtrim($this->getBasicInfo()['url'], '/').($withTrailingSlash ? '/' : '');
131 131
     }
132 132
 
133 133
     /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $metadata = $this->getMetadata();
185 185
         return isset($metadata['general']['script'])
186 186
             ? $metadata['general']['script']
187
-            : $this->getScriptPath() . '/index.php';
187
+            : $this->getScriptPath().'/index.php';
188 188
     }
189 189
 
190 190
     /**
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     public function getApiUrl()
196 196
     {
197
-        return rtrim($this->getUrl(), '/') . $this->getRepository()->getApiPath();
197
+        return rtrim($this->getUrl(), '/').$this->getRepository()->getApiPath();
198 198
     }
199 199
 
200 200
     /**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function userOptInPage(User $user)
260 260
     {
261
-        $localPageName = 'User:' . $user->getUsername() . '/EditCounterOptIn.js';
261
+        $localPageName = 'User:'.$user->getUsername().'/EditCounterOptIn.js';
262 262
         return $localPageName;
263 263
     }
264 264
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         }
294 294
 
295 295
         // 4. Lastly, see if they've opted in globally on the default project or Meta.
296
-        $globalPageName = $user->getUsername() . '/EditCounterGlobalOptIn.js';
296
+        $globalPageName = $user->getUsername().'/EditCounterGlobalOptIn.js';
297 297
         $globalProject = $this->getRepository()->getGlobalProject();
298 298
         if ($globalProject instanceof Project) {
299 299
             $globalExists = $globalProject->getRepository()
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      */
313 313
     public function hasPageAssessments()
314 314
     {
315
-        return (bool) $this->getRepository()->getAssessmentsConfig($this->getDomain());
315
+        return (bool)$this->getRepository()->getAssessmentsConfig($this->getDomain());
316 316
     }
317 317
 
318 318
     /**
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
         $config = $this->getRepository()->getAssessmentsConfig($this->getDomain());
327 327
 
328 328
         if (isset($config['class'][$class])) {
329
-            $url = "https://upload.wikimedia.org/wikipedia/commons/" . $config['class'][$class]['badge'];
329
+            $url = "https://upload.wikimedia.org/wikipedia/commons/".$config['class'][$class]['badge'];
330 330
         } elseif (isset($config['class']['Unknown'])) {
331
-            $url = "https://upload.wikimedia.org/wikipedia/commons/" . $config['class']['Unknown']['badge'];
331
+            $url = "https://upload.wikimedia.org/wikipedia/commons/".$config['class']['Unknown']['badge'];
332 332
         } else {
333 333
             $url = "";
334 334
         }
Please login to merge, or discard this patch.
src/AppBundle/EventSubscriber/RateLimitSubscriber.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function onKernelController(FilterControllerEvent $event)
58 58
     {
59
-        $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count');
60
-        $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time');
59
+        $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count');
60
+        $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time');
61 61
 
62 62
         // Zero values indicate the rate limiting feature should be disabled.
63 63
         if ($this->rateLimit === 0 || $this->rateDuration === 0) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         $controller = $event->getController();
68
-        $loggedIn = (bool) $this->container->get('session')->get('logged_in_user');
68
+        $loggedIn = (bool)$this->container->get('session')->get('logged_in_user');
69 69
 
70 70
         /**
71 71
          * Rate limiting will not apply to these actions
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $cacheItem = $cache->getItem($cacheKey);
92 92
 
93 93
         // If increment value already in cache, or start with 1.
94
-        $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1;
94
+        $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1;
95 95
 
96 96
         // Check if limit has been exceeded, and if so, throw an error.
97 97
         if ($count > $this->rateLimit) {
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
         // Log the denied request
144 144
         $logger = $this->container->get('monolog.logger.rate_limit');
145 145
         $logger->info(
146
-            "<URI>: " . $request->getRequestUri() .
147
-            ($logComment != '' ? "\t<Reason>: $logComment" : '') .
148
-            "\t<User agent>: " . $request->headers->get('User-Agent')
146
+            "<URI>: ".$request->getRequestUri().
147
+            ($logComment != '' ? "\t<Reason>: $logComment" : '').
148
+            "\t<User agent>: ".$request->headers->get('User-Agent')
149 149
         );
150 150
 
151 151
         throw new TooManyRequestsHttpException(600, 'error-rate-limit', null, $this->rateDuration);
Please login to merge, or discard this patch.
src/Xtools/EditCounterRepository.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
         ])->fetchAll();
127 127
 
128 128
         $logCounts = array_combine(
129
-            array_map(function ($e) {
129
+            array_map(function($e) {
130 130
                 return $e['source'];
131 131
             }, $results),
132
-            array_map(function ($e) {
132
+            array_map(function($e) {
133 133
                 return $e['value'];
134 134
             }, $results)
135 135
         );
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
             'id' => $user->getId($project),
368 368
         ])->fetchAll();
369 369
 
370
-        $namespaceTotals = array_combine(array_map(function ($e) {
370
+        $namespaceTotals = array_combine(array_map(function($e) {
371 371
             return $e['page_namespace'];
372
-        }, $results), array_map(function ($e) {
372
+        }, $results), array_map(function($e) {
373 373
             return $e['total'];
374 374
         }, $results));
375 375
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             }
424 424
             $queries[] = $sql;
425 425
         }
426
-        $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n";
426
+        $sql = "(\n".join("\n) UNION (\n", $queries).")\n";
427 427
 
428 428
         $revisions = $this->executeProjectsQuery($sql, [
429 429
             'username' => $user->getUsername(),
Please login to merge, or discard this patch.
src/Xtools/AutoEditsRepository.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $tagJoin = $tags != '' ? "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id" : '';
53 53
             $condTools[] = "ct_tag IN ($tags)";
54 54
         }
55
-        $condTool = 'AND (' . implode(' OR ', $condTools) . ')';
55
+        $condTool = 'AND ('.implode(' OR ', $condTools).')';
56 56
 
57 57
         $sql = "SELECT COUNT(DISTINCT(rev_id))
58 58
                 FROM $revisionTable
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
                 $condEnd";
66 66
 
67 67
         $resultQuery = $this->executeQuery($sql, $user, $namespace, $start, $end);
68
-        $result = (int) $resultQuery->fetchColumn();
68
+        $result = (int)$resultQuery->fetchColumn();
69 69
 
70 70
         // Cache and return.
71 71
         $this->stopwatch->stop($cacheKey);
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
         }
191 191
 
192 192
         // Sort the array by count
193
-        uasort($results, function ($a, $b) {
194
-            return $b['count'] - $a['count'];
193
+        uasort($results, function($a, $b) {
194
+            return $b['count']-$a['count'];
195 195
         });
196 196
 
197 197
         // Cache and return.
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
             // Developer error, no regex or tag provided for this tool.
235 235
             if ($condTool === '') {
236
-                throw new Exception("No regex or tag found for the tool $toolname. " .
236
+                throw new Exception("No regex or tag found for the tool $toolname. ".
237 237
                     "Please verify this entry in semi_automated.yml");
238 238
             }
239 239
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
             if ($condTool === '') {
280 280
                 $condTool = "ct_tag = $tag";
281 281
             } else {
282
-                $condTool = '(' . $condTool . " OR ct_tag = $tag)";
282
+                $condTool = '('.$condTool." OR ct_tag = $tag)";
283 283
             }
284 284
         }
285 285
 
Please login to merge, or discard this patch.
src/AppBundle/Controller/ArticleInfoController.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
             $rendered = str_replace('"', '\"', trim($rendered));
87 87
 
88 88
             // Uglify temporary file.
89
-            $tmpFile = sys_get_temp_dir() . '/xtools_articleinfo_gadget.js';
89
+            $tmpFile = sys_get_temp_dir().'/xtools_articleinfo_gadget.js';
90 90
             $script = "echo \"$rendered\" | tee $tmpFile >/dev/null && ";
91
-            $script .= $this->get('kernel')->getRootDir() .
92
-                "/Resources/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle " .
91
+            $script .= $this->get('kernel')->getRootDir().
92
+                "/Resources/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle ".
93 93
                 "&& rm $tmpFile >/dev/null";
94 94
             $process = new Process($script);
95 95
             $process->run();
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
             $rendered = str_replace('\"', '"', trim($rendered));
109 109
 
110 110
             // Add comment after uglifying since it removes comments.
111
-            $rendered = "/**\n * This code was automatically generated and should not " .
112
-                "be manually edited.\n * For updates, please copy and paste from " .
113
-                $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL) .
114
-                "\n * Released under GPL v3 license.\n */\n" . $rendered;
111
+            $rendered = "/**\n * This code was automatically generated and should not ".
112
+                "be manually edited.\n * For updates, please copy and paste from ".
113
+                $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL).
114
+                "\n * Released under GPL v3 license.\n */\n".$rendered;
115 115
         }
116 116
 
117 117
         $response = new \Symfony\Component\HttpFoundation\Response($rendered);
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $data = [
337 337
             'project' => $project->getDomain(),
338 338
             'page' => $page->getTitle(),
339
-            'watchers' => (int) $page->getWatchers(),
339
+            'watchers' => (int)$page->getWatchers(),
340 340
             'pageviews' => $page->getLastPageviews($pageviewsOffset),
341 341
             'pageviews_offset' => $pageviewsOffset,
342 342
         ];
@@ -357,18 +357,18 @@  discard block
 block discarded – undo
357 357
         if ($info != false) {
358 358
             $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']);
359 359
             $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']);
360
-            $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp();
360
+            $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp();
361 361
 
362 362
             $data = array_merge($data, [
363
-                'revisions' => (int) $info['num_edits'],
364
-                'editors' => (int) $info['num_editors'],
363
+                'revisions' => (int)$info['num_edits'],
364
+                'editors' => (int)$info['num_editors'],
365 365
                 'author' => $info['author'],
366
-                'author_editcount' => (int) $info['author_editcount'],
366
+                'author_editcount' => (int)$info['author_editcount'],
367 367
                 'created_at' => $creationDateTime->format('Y-m-d'),
368 368
                 'created_rev_id' => $info['created_rev_id'],
369 369
                 'modified_at' => $modifiedDateTime->format('Y-m-d H:i'),
370 370
                 'secs_since_last_edit' => $secsSinceLastEdit,
371
-                'last_edit_id' => (int) $info['modified_rev_id'],
371
+                'last_edit_id' => (int)$info['modified_rev_id'],
372 372
             ]);
373 373
         }
374 374
 
Please login to merge, or discard this patch.
src/Xtools/Repository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
             return;
106 106
         }
107 107
 
108
-        $requestTime = microtime(true) - $request->server->get('REQUEST_TIME_FLOAT');
108
+        $requestTime = microtime(true)-$request->server->get('REQUEST_TIME_FLOAT');
109 109
 
110 110
         return [
111 111
             'requestTime' => round($requestTime, 2),
Please login to merge, or discard this patch.
src/AppBundle/Helper/AutomatedEditsHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -157,14 +157,14 @@
 block discarded – undo
157 157
 
158 158
         $revertEntries = array_filter(
159 159
             $this->getTools($project),
160
-            function ($tool) {
160
+            function($tool) {
161 161
                 return isset($tool['revert']);
162 162
             }
163 163
         );
164 164
 
165 165
         // If 'revert' is set to `true`, then use 'regex' as the regular expression,
166 166
         //  otherwise 'revert' is assumed to be the regex string.
167
-        $this->revertTools[$projectDomain] = array_map(function ($revertTool) {
167
+        $this->revertTools[$projectDomain] = array_map(function($revertTool) {
168 168
             return [
169 169
                 'link' => $revertTool['link'],
170 170
                 'regex' => $revertTool['revert'] === true ? $revertTool['regex'] : $revertTool['revert'],
Please login to merge, or discard this patch.