Passed
Branch dbdriver-refactor (3762aa)
by MusikAnimal
04:48
created
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);
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $data = [
220 220
             'project' => $project->getDomain(),
221 221
             'page' => $page->getTitle(),
222
-            'watchers' => (int) $page->getWatchers(),
222
+            'watchers' => (int)$page->getWatchers(),
223 223
             'pageviews' => $page->getLastPageviews($pageviewsOffset),
224 224
             'pageviews_offset' => $pageviewsOffset,
225 225
         ];
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
         if (isset($info)) {
240 240
             $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']);
241 241
             $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']);
242
-            $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp();
242
+            $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp();
243 243
 
244 244
             $data = array_merge($data, [
245
-                'revisions' => (int) $info['num_edits'],
246
-                'editors' => (int) $info['num_editors'],
245
+                'revisions' => (int)$info['num_edits'],
246
+                'editors' => (int)$info['num_editors'],
247 247
                 'author' => $info['author'],
248
-                'author_editcount' => (int) $info['author_editcount'],
248
+                'author_editcount' => (int)$info['author_editcount'],
249 249
                 'created_at' => $creationDateTime->format('Y-m-d'),
250 250
                 'created_rev_id' => $info['created_rev_id'],
251 251
                 'modified_at' => $modifiedDateTime->format('Y-m-d H:i'),
252 252
                 'secs_since_last_edit' => $secsSinceLastEdit,
253
-                'last_edit_id' => (int) $info['modified_rev_id'],
253
+                'last_edit_id' => (int)$info['modified_rev_id'],
254 254
             ]);
255 255
         }
256 256
 
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/PageRepository.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         // supply as the OFFSET.
152 152
         $limitClause = '';
153 153
         if (intval($limit) > 0 && isset($numRevisions)) {
154
-            $offset = $numRevisions - $limit;
154
+            $offset = $numRevisions-$limit;
155 155
             $limitClause = "LIMIT $offset, $limit";
156 156
         }
157 157
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         $time2 = time();
291 291
 
292 292
         // If it took over 5 seconds, cache the result for 20 minutes.
293
-        if ($time2 - $time1 > 5) {
293
+        if ($time2-$time1 > 5) {
294 294
             $this->setCache($cacheKey, $result, 'PT20M');
295 295
         }
296 296
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 
410 410
         $wikidataId = ltrim($page->getWikidataId(), 'Q');
411 411
 
412
-        $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . "
412
+        $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')."
413 413
                 FROM wikidatawiki_p.wb_items_per_site
414 414
                 WHERE ips_item_id = :wikidataId";
415 415
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
             'wikidataId' => $wikidataId,
418 418
         ])->fetchAll();
419 419
 
420
-        return $count ? (int) $result[0]['count'] : $result;
420
+        return $count ? (int)$result[0]['count'] : $result;
421 421
     }
422 422
 
423 423
     /**
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 
456 456
         // Transform to associative array by 'type'
457 457
         foreach ($res as $row) {
458
-            $data[$row['type'] . '_count'] = $row['value'];
458
+            $data[$row['type'].'_count'] = $row['value'];
459 459
         }
460 460
 
461 461
         return $data;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
         $project = $page->getProject()->getDomain();
499 499
 
500
-        $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' .
500
+        $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'.
501 501
             "$project/all-access/user/$title/daily/$start/$end";
502 502
 
503 503
         $res = $client->request('GET', $url);
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/ProjectRepository.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -330,9 +330,9 @@
 block discarded – undo
330 330
     {
331 331
         $pageTable = $this->getTableName($project->getDatabaseName(), 'page');
332 332
         $query = "SELECT page_id "
333
-             . " FROM $pageTable "
334
-             . " WHERE page_namespace = :ns AND page_title = :title AND page_len > 0 "
335
-             . " LIMIT 1";
333
+                . " FROM $pageTable "
334
+                . " WHERE page_namespace = :ns AND page_title = :title AND page_len > 0 "
335
+                . " LIMIT 1";
336 336
         $params = [
337 337
             'ns' => $namespaceId,
338 338
             'title' => str_replace(' ', '_', $pageTitle),
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.