Completed
Pull Request — master (#15)
by Sam
02:42
created
src/AppBundle/Helper/EditCounterHelper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
 
147 147
     /**
148 148
      *
149
-     * @param $username
149
+     * @param string $username
150 150
      * @return integer
151 151
      */
152 152
     public function getPageCounts($username, $totalRevisions)
Please login to merge, or discard this patch.
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -2,12 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace AppBundle\Helper;
4 4
 
5
-use AppBundle\Twig\AppExtension;
6
-use DateInterval;
7 5
 use Doctrine\DBAL\Connection;
8 6
 use Exception;
9 7
 use Symfony\Component\DependencyInjection\Container;
10
-use Symfony\Component\VarDumper\VarDumper;
11 8
 
12 9
 class EditCounterHelper extends HelperBase
13 10
 {
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function getUserId($usernameOrIp)
37 37
     {
38
-        $cacheKey = 'userid.' . $usernameOrIp;
38
+        $cacheKey = 'userid.'.$usernameOrIp;
39 39
         if ($this->cacheHas($cacheKey)) {
40 40
             return $cacheKey;
41 41
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $topEditCounts = [];
62 62
         foreach ($this->labsHelper->allProjects() as $project) {
63
-            $cacheKey = 'topprojects.' . $project['dbName'] . '.' . $username;
63
+            $cacheKey = 'topprojects.'.$project['dbName'].'.'.$username;
64 64
             if ($this->cacheHas($cacheKey)) {
65 65
                 $total = $this->cacheGet($cacheKey);
66 66
             } else {
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
             }
77 77
             $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]);
78 78
         }
79
-        uasort($topEditCounts, function ($a, $b) {
80
-            return $b['total'] - $a['total'];
79
+        uasort($topEditCounts, function($a, $b) {
80
+            return $b['total']-$a['total'];
81 81
         });
82 82
         return array_slice($topEditCounts, 0, $numProjects);
83 83
     }
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
         }
148 148
 
149 149
         $revisionCounts = array_combine(
150
-            array_map(function ($e) {
150
+            array_map(function($e) {
151 151
                 return $e['source'];
152 152
             }, $results),
153
-            array_map(function ($e) {
153
+            array_map(function($e) {
154 154
                 return $e['value'];
155 155
             }, $results)
156 156
         );
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
         // Count the number of days, accounting for when there's zero or one edit.
159 159
         $revisionCounts['days'] = 0;
160 160
         if (isset($revisionCounts['first']) && isset($revisionCounts['last'])) {
161
-            $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']);
162
-            $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1;
161
+            $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']);
162
+            $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1;
163 163
         }
164 164
 
165 165
         // Format the first and last dates.
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             : 0;
172 172
 
173 173
         // Sum deleted and live to make the total.
174
-        $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live'];
174
+        $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live'];
175 175
 
176 176
         // Calculate the average number of live edits per day.
177 177
         $revisionCounts['avg_per_day'] = round(
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
         $results = $resultQuery->fetchAll();
216 216
 
217 217
         $pageCounts = array_combine(
218
-            array_map(function ($e) {
218
+            array_map(function($e) {
219 219
                 return $e['source'];
220 220
             }, $results),
221
-            array_map(function ($e) {
221
+            array_map(function($e) {
222 222
                 return $e['value'];
223 223
             }, $results)
224 224
         );
225 225
 
226 226
         // Total created.
227
-        $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted'];
227
+        $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted'];
228 228
 
229 229
         // Calculate the average number of edits per page.
230 230
         $pageCounts['edits_per_page'] = 0;
@@ -253,17 +253,17 @@  discard block
 block discarded – undo
253 253
         $resultQuery->execute();
254 254
         $results = $resultQuery->fetchAll();
255 255
         $logCounts = array_combine(
256
-            array_map(function ($e) {
256
+            array_map(function($e) {
257 257
                 return $e['source'];
258 258
             }, $results),
259
-            array_map(function ($e) {
259
+            array_map(function($e) {
260 260
                 return $e['value'];
261 261
             }, $results)
262 262
         );
263 263
 
264 264
         // Make sure there is some value for each of the wanted counts.
265 265
         $requiredCounts = [
266
-            'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock',
266
+            'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock',
267 267
             'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision',
268 268
             'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite',
269 269
         ];
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         // Merge approvals together.
277
-        $logCounts['review-approve'] = $logCounts['review-approve'] +
278
-            (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
279
-            (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
277
+        $logCounts['review-approve'] = $logCounts['review-approve']+
278
+            (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
279
+            (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
280 280
             (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
281 281
 
282 282
         // Add Commons upload count, if applicable.
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     {
303 303
         $userId = $this->getUserId($username);
304 304
         $sql = "SELECT page_namespace, count(rev_id) AS total
305
-            FROM ".$this->labsHelper->getTable('revision') ." r
305
+            FROM ".$this->labsHelper->getTable('revision')." r
306 306
                 JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id
307 307
             WHERE r.rev_user = :id GROUP BY page_namespace";
308 308
         $resultQuery = $this->replicas->prepare($sql);
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
         $resultQuery->execute();
311 311
         $results = $resultQuery->fetchAll();
312 312
         $namespaceTotals = array_combine(
313
-            array_map(function ($e) {
313
+            array_map(function($e) {
314 314
                 return $e['page_namespace'];
315 315
             }, $results),
316
-            array_map(function ($e) {
316
+            array_map(function($e) {
317 317
                 return $e['total'];
318 318
             }, $results)
319 319
         );
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
                     "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, "
340 340
                     . " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, "
341 341
                     . " page_title, page_namespace "
342
-                    . " FROM " . $this->labsHelper->getTable('revision', $project['dbName'])
343
-                    . "    JOIN " . $this->labsHelper->getTable('page', $project['dbName'])
342
+                    . " FROM ".$this->labsHelper->getTable('revision', $project['dbName'])
343
+                    . "    JOIN ".$this->labsHelper->getTable('page', $project['dbName'])
344 344
                     . "    ON (rev_page = page_id)"
345 345
                     . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username"
346 346
                     . " ORDER BY rev_timestamp DESC"
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                 continue;
356 356
             }
357 357
             $revsWithProject = array_map(
358
-                function (&$item) use ($project) {
358
+                function(&$item) use ($project) {
359 359
                     $item['project_name'] = $project['name'];
360 360
                     $item['project_url'] = $project['url'];
361 361
                     $item['project_db_name'] = $project['dbName'];
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
             );
367 367
             $allRevisions = array_merge($allRevisions, $revsWithProject);
368 368
         }
369
-        usort($allRevisions, function ($a, $b) {
370
-            return $b['rev_timestamp'] - $a['rev_timestamp'];
369
+        usort($allRevisions, function($a, $b) {
370
+            return $b['rev_timestamp']-$a['rev_timestamp'];
371 371
         });
372 372
         return array_slice($allRevisions, 0, $contribCount);
373 373
     }
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
             . "     MONTH(rev_timestamp) AS `month`,"
390 390
             . "     page_namespace,"
391 391
             . "     COUNT(rev_id) AS `count` "
392
-            . " FROM " . $this->labsHelper->getTable('revision')
393
-            . "    JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)"
392
+            . " FROM ".$this->labsHelper->getTable('revision')
393
+            . "    JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)"
394 394
             . " WHERE rev_user_text = :username"
395 395
             . " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace "
396 396
             . " ORDER BY rev_timestamp DESC";
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
             . "     SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`,"
447 447
             . "     page_namespace,"
448 448
             . "     COUNT(rev_id) AS `count` "
449
-            . " FROM " . $this->labsHelper->getTable('revision')
450
-            . "    JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" .
451
-            " WHERE rev_user_text = :username" .
452
-            " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " .
449
+            . " FROM ".$this->labsHelper->getTable('revision')
450
+            . "    JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)".
451
+            " WHERE rev_user_text = :username".
452
+            " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ".
453 453
             " ORDER BY rev_timestamp DESC ";
454 454
         $resultQuery = $this->replicas->prepare($sql);
455 455
         $resultQuery->bindParam(":username", $username);
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             . "     DAYOFWEEK(rev_timestamp) AS `y`, "
491 491
             . "     $xCalc AS `x`, "
492 492
             . "     COUNT(rev_id) AS `r` "
493
-            . " FROM " . $this->labsHelper->getTable('revision')
493
+            . " FROM ".$this->labsHelper->getTable('revision')
494 494
             . " WHERE rev_user_text = :username"
495 495
             . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc "
496 496
             . " ";
Please login to merge, or discard this patch.
src/AppBundle/Helper/AutomatedEditsHelper.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
         /** @var LabsHelper $labsHelper */
126 126
         $labsHelper = $this->container->get('app.labs_helper');
127 127
         $sql = "SELECT rev_comment FROM ".$labsHelper->getTable('revision')
128
-               ." WHERE rev_user=:userId ORDER BY rev_timestamp DESC LIMIT 1000";
128
+                ." WHERE rev_user=:userId ORDER BY rev_timestamp DESC LIMIT 1000";
129 129
         $resultQuery = $replicas->prepare($sql);
130 130
         $resultQuery->bindParam("userId", $userId);
131 131
         $resultQuery->execute();
Please login to merge, or discard this patch.
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -3,11 +3,7 @@
 block discarded – undo
3 3
 namespace AppBundle\Helper;
4 4
 
5 5
 use Doctrine\DBAL\Connection;
6
-use Psr\Cache\CacheItemPoolInterface;
7
-use Symfony\Component\Config\Definition\Exception\Exception;
8
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9 6
 use Symfony\Component\DependencyInjection\ContainerInterface;
10
-use Symfony\Component\VarDumper\VarDumper;
11 7
 
12 8
 class AutomatedEditsHelper extends HelperBase
13 9
 {
Please login to merge, or discard this patch.
src/AppBundle/Twig/WikiExtension.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,7 +72,6 @@  discard block
 block discarded – undo
72 72
 
73 73
     /**
74 74
      * Get a link to the given user's userpage, or to Special:Contribs if $username is an IP
75
-     * @param  string $username   Username
76 75
      * @param  string $projectUrl Project domain and protocol such as https://en.wikipedia.org
77 76
      * @param  string [$label]    The link text, defaults to $username
78 77
      * @return string Markup
@@ -176,7 +175,7 @@  discard block
 block discarded – undo
176 175
     /**
177 176
      * Get links to pageviews tools for the given page
178 177
      * @param  string $title      Title of page
179
-     * @param  string $projectUrl Project domain such as en.wikipedia.org
178
+     * @param  string $project Project domain such as en.wikipedia.org
180 179
      * @return string Markup
181 180
      */
182 181
     public function pageviewsLinks($title, $project)
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@  discard block
 block discarded – undo
14 14
 
15 15
     public function intuitionMessage($message = "", $vars = [])
16 16
     {
17
-        return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]);
17
+        return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]);
18 18
     }
19 19
 
20 20
     /*********************************** FUNCTIONS ***********************************/
21 21
 
22 22
     public function getFunctions()
23 23
     {
24
-        $options = [ 'is_safe' => [ 'html']];
24
+        $options = ['is_safe' => ['html']];
25 25
         return [
26
-            new Twig_SimpleFunction('wiki_link', [ $this, 'wikiLink' ], $options),
27
-            new Twig_SimpleFunction('user_link', [ $this, 'userLink' ], $options),
28
-            new Twig_SimpleFunction('user_log_link', [ $this, 'userLogLink' ], $options),
29
-            new Twig_SimpleFunction('group_link', [ $this, 'groupLink' ], $options),
30
-            new Twig_SimpleFunction('wiki_history_link', [ $this, 'wikiHistoryLink' ], $options),
31
-            new Twig_SimpleFunction('wiki_log_link', [ $this, 'wikiLogLink' ], $options),
32
-            new Twig_SimpleFunction('pageviews_links', [ $this, 'pageviewsLinks' ], $options),
33
-            new Twig_SimpleFunction('diff_link', [ $this, 'diffLink' ], $options),
34
-            new Twig_SimpleFunction('perma_link', [ $this, 'permaLink' ], $options),
35
-            new Twig_SimpleFunction('edit_link', [ $this, 'editLink' ], $options),
26
+            new Twig_SimpleFunction('wiki_link', [$this, 'wikiLink'], $options),
27
+            new Twig_SimpleFunction('user_link', [$this, 'userLink'], $options),
28
+            new Twig_SimpleFunction('user_log_link', [$this, 'userLogLink'], $options),
29
+            new Twig_SimpleFunction('group_link', [$this, 'groupLink'], $options),
30
+            new Twig_SimpleFunction('wiki_history_link', [$this, 'wikiHistoryLink'], $options),
31
+            new Twig_SimpleFunction('wiki_log_link', [$this, 'wikiLogLink'], $options),
32
+            new Twig_SimpleFunction('pageviews_links', [$this, 'pageviewsLinks'], $options),
33
+            new Twig_SimpleFunction('diff_link', [$this, 'diffLink'], $options),
34
+            new Twig_SimpleFunction('perma_link', [$this, 'permaLink'], $options),
35
+            new Twig_SimpleFunction('edit_link', [$this, 'editLink'], $options),
36 36
         ];
37 37
     }
38 38
 
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
     public function getFilters()
245 245
     {
246 246
         return [
247
-            new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]),
248
-            new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]),
249
-            new \Twig_SimpleFilter('wikify_comment', [ $this, 'wikifyComment' ], [ 'is_safe' => [ 'html' ] ]),
247
+            new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']),
248
+            new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]),
249
+            new \Twig_SimpleFilter('wikify_comment', [$this, 'wikifyComment'], ['is_safe' => ['html']]),
250 250
         ];
251 251
     }
252 252
 
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
         if (!$denominator) {
283 283
             $quotient = $numerator;
284 284
         } else {
285
-            $quotient = ( $numerator / $denominator ) * 100;
285
+            $quotient = ($numerator / $denominator) * 100;
286 286
         }
287 287
 
288
-        return round($quotient, $precision) . '%';
288
+        return round($quotient, $precision).'%';
289 289
     }
290 290
 
291 291
     /**
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         if ($isSection) {
304 304
             $sectionTitle = $sectionMatch[1][0];
305 305
             $sectionTitleLink = str_replace(' ', '_', $sectionTitle);
306
-            $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>&rarr;</a>" .
306
+            $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>&rarr;</a>".
307 307
                 "<em class='text-muted'>$sectionTitle:</em> ";
308 308
             $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext);
309 309
         }
Please login to merge, or discard this patch.
src/AppBundle/Controller/AdminStatsController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@
 block discarded – undo
176 176
 
177 177
         // Iterate over query results, loading each user id into the array
178 178
         while ($row = $res->fetch()) {
179
-            $adminIdArr[] = $row["user_id"] ;
179
+            $adminIdArr[] = $row["user_id"];
180 180
         }
181 181
 
182 182
         // Set the query results to be useful in a sql statement.
Please login to merge, or discard this patch.
src/AppBundle/Helper/ApiHelper.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -52,6 +52,9 @@  discard block
 block discarded – undo
52 52
         }
53 53
     }
54 54
 
55
+    /**
56
+     * @param string $username
57
+     */
55 58
     public function groups($project, $username)
56 59
     {
57 60
         $this->setUp($project);
@@ -71,6 +74,9 @@  discard block
 block discarded – undo
71 74
         return $result;
72 75
     }
73 76
 
77
+    /**
78
+     * @param string $username
79
+     */
74 80
     public function globalGroups($project, $username)
75 81
     {
76 82
         $this->setUp($project);
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace AppBundle\Helper;
4 4
 
5
-use DateInterval;
6 5
 use Mediawiki\Api\MediawikiApi;
7 6
 use Mediawiki\Api\SimpleRequest;
8 7
 use Mediawiki\Api\FluentRequest;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function groups($project, $username)
56 56
     {
57 57
         $this->setUp($project);
58
-        $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ];
58
+        $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"];
59 59
         $query = new SimpleRequest('query', $params);
60 60
         $result = [];
61 61
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     public function globalGroups($project, $username)
75 75
     {
76 76
         $this->setUp($project);
77
-        $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ];
77
+        $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"];
78 78
         $query = new SimpleRequest('query', $params);
79 79
         $result = [];
80 80
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         }
105 105
 
106 106
         $this->setUp($project);
107
-        $query = new SimpleRequest('query', [ "meta"=>"siteinfo", "siprop"=>"namespaces" ]);
107
+        $query = new SimpleRequest('query', ["meta"=>"siteinfo", "siprop"=>"namespaces"]);
108 108
         $namespaces = [];
109 109
 
110 110
         try {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 $groups[] = "B";
161 161
             }
162 162
             if (in_array("steward", $admin["groups"])) {
163
-                $groups[] = "S" ;
163
+                $groups[] = "S";
164 164
             }
165 165
             if (in_array("checkuser", $admin["groups"])) {
166 166
                 $groups[] = "CU";
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             if (in_array("bot", $admin["groups"])) {
172 172
                 $groups[] = "Bot";
173 173
             }
174
-            $result[ $admin["name"] ] = [
174
+            $result[$admin["name"]] = [
175 175
                 "groups" => implode('/', $groups)
176 176
             ];
177 177
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
             $normalized = [];
247 247
             if (isset($result['query']['normalized'])) {
248 248
                 array_map(
249
-                    function ($e) use (&$normalized) {
249
+                    function($e) use (&$normalized) {
250 250
                         $normalized[$e['to']] = $e['from'];
251 251
                     },
252 252
                     $result['query']['normalized']
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
         ];
293 293
 
294 294
         // get assessments for this page from the API
295
-        $assessments = $this->massApi($params, $project, function ($data) {
295
+        $assessments = $this->massApi($params, $project, function($data) {
296 296
             return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : [];
297 297
         }, 'pacontinue')['pages'];
298 298
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
                 $classAttrs = $config['class']['Unknown'];
317 317
                 $assessment['class']['value'] = '???';
318 318
                 $assessment['class']['category'] = $classAttrs['category'];
319
-                $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge'];
319
+                $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge'];
320 320
             } else {
321 321
                 $classAttrs = $config['class'][$classValue];
322 322
                 $assessment['class'] = [
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
                 // add full URL to badge icon
329 329
                 if ($classAttrs['badge'] !== '') {
330
-                    $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" .
330
+                    $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".
331 331
                         $classAttrs['badge'];
332 332
                 }
333 333
 
@@ -376,9 +376,9 @@  discard block
 block discarded – undo
376 376
         $config = $this->getAssessmentsConfig();
377 377
 
378 378
         if (isset($config[$project]['class'][$class])) {
379
-            return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge'];
379
+            return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge'];
380 380
         } elseif (isset($config[$project]['class']['Unknown'])) {
381
-            return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge'];
381
+            return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge'];
382 382
         } else {
383 383
             return "";
384 384
         }
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
         $query = FluentRequest::factory()->setAction('query')->setParams($requestData);
472 472
         $innerPromise = $this->api->getRequestAsync($query);
473 473
 
474
-        $innerPromise->then(function ($result) use (&$data) {
474
+        $innerPromise->then(function($result) use (&$data) {
475 475
             // some failures come back as 200s, so we still resolve and let the outer function handle it
476 476
             if (isset($result['error']) || !isset($result['query'])) {
477 477
                 return $data['promise']->resolve($data);
Please login to merge, or discard this patch.
src/AppBundle/Helper/LabsHelper.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use Symfony\Component\Config\Definition\Exception\Exception;
6 6
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7 7
 use Symfony\Component\DependencyInjection\ContainerInterface;
8
-use Symfony\Component\VarDumper\VarDumper;
9 8
 
10 9
 class LabsHelper
11 10
 {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             // Create the query we're going to run against the meta database
62 62
             $wikiQuery = $this->client->createQueryBuilder();
63 63
             $wikiQuery
64
-                ->select([ 'dbName', 'name', 'url', 'lang' ])
64
+                ->select(['dbName', 'name', 'url', 'lang'])
65 65
                 ->from('wiki')
66 66
                 ->where($wikiQuery->expr()->eq('dbname', ':project'))
67 67
                 // The meta database will have the project's URL stored as https://en.wikipedia.org
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $this->dbName = $dbName;
101 101
         $this->url = $url;
102 102
 
103
-        return [ 'dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang ];
103
+        return ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang];
104 104
     }
105 105
 
106 106
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     public function allProjects()
110 110
     {
111 111
         $wikiQuery = $this->client->createQueryBuilder();
112
-        $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki');
112
+        $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki');
113 113
         $stmt = $wikiQuery->execute();
114 114
         $out = $stmt->fetchAll();
115 115
         return $out;
Please login to merge, or discard this patch.
src/AppBundle/Twig/AppExtension.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@  discard block
 block discarded – undo
16 16
     {
17 17
         $options = ['is_safe' => ['html']];
18 18
         return [
19
-            new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options),
20
-            new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options),
21
-            new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options),
22
-            new \Twig_SimpleFunction('linkWiki', [ $this, 'linkToWiki' ], $options),
23
-            new \Twig_SimpleFunction('linkWikiScript', [ $this, 'linkToWikiScript' ], $options),
24
-            new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options),
25
-            new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options),
26
-            new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options),
27
-            new \Twig_SimpleFunction('msg_footer', [ $this, 'intuitionMessageFooter' ], $options),
28
-            new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options),
29
-            new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options),
30
-            new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]),
31
-            new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]),
32
-            new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]),
33
-            new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]),
34
-            new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]),
35
-            new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]),
36
-            new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]),
37
-            new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]),
38
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
39
-            new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]),
40
-            new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]),
41
-            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]),
42
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
43
-            new \Twig_SimpleFunction('replag', [ $this, 'replag' ]),
44
-            new \Twig_SimpleFunction('link', [ $this, 'link' ]),
19
+            new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options),
20
+            new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options),
21
+            new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options),
22
+            new \Twig_SimpleFunction('linkWiki', [$this, 'linkToWiki'], $options),
23
+            new \Twig_SimpleFunction('linkWikiScript', [$this, 'linkToWikiScript'], $options),
24
+            new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options),
25
+            new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options),
26
+            new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options),
27
+            new \Twig_SimpleFunction('msg_footer', [$this, 'intuitionMessageFooter'], $options),
28
+            new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options),
29
+            new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options),
30
+            new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']),
31
+            new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']),
32
+            new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']),
33
+            new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']),
34
+            new \Twig_SimpleFunction('hash', [$this, 'gitHash']),
35
+            new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']),
36
+            new \Twig_SimpleFunction('tools', [$this, 'allTools']),
37
+            new \Twig_SimpleFunction('color', [$this, 'getColorList']),
38
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
39
+            new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']),
40
+            new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']),
41
+            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']),
42
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
43
+            new \Twig_SimpleFunction('replag', [$this, 'replag']),
44
+            new \Twig_SimpleFunction('link', [$this, 'link']),
45 45
         ];
46 46
     }
47 47
 
48 48
     public function requestTime($decimals = 3)
49 49
     {
50 50
 
51
-        return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals);
51
+        return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals);
52 52
     }
53 53
 
54 54
     public function requestMemory()
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function linkToWiki($url, $page, $secondary = "")
76 76
     {
77
-        $link = $url . "/";
77
+        $link = $url."/";
78 78
 
79 79
         if ($this->isWMFLabs()) {
80 80
             $link .= "wiki/";
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
     public function linkToWikiScript($url, $secondary)
93 93
     {
94
-        $link = $url . "/";
94
+        $link = $url."/";
95 95
 
96 96
         if ($this->isWMFLabs()) {
97 97
             $link .= "w/";
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     // TODO: refactor all intuition stuff so it can be used anywhere
108 108
     public function intuitionMessageExists($message = "")
109 109
     {
110
-        return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]);
110
+        return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]);
111 111
     }
112 112
 
113 113
     public function intuitionMessagePrintExists($message = "", $vars = [])
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
     public function intuitionMessage($message = "", $vars = [])
128 128
     {
129
-        return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]);
129
+        return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]);
130 130
     }
131 131
 
132 132
     public function intuitionMessageFooter()
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function getAllLangs()
156 156
     {
157
-        $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json');
157
+        $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json');
158 158
 
159 159
         $languages = array_values(array_unique(array_map(
160
-            function ($filename) {
160
+            function($filename) {
161 161
                 return basename($filename, '.json');
162 162
             },
163 163
             $messageFiles
@@ -214,41 +214,41 @@  discard block
 block discarded – undo
214 214
     public static function getColorList($num = false)
215 215
     {
216 216
         $colors = [
217
-            0 => '#Cc0000',# '#FF005A', #red '#FF5555',
217
+            0 => '#Cc0000', # '#FF005A', #red '#FF5555',
218 218
             1 => '#F7b7b7',
219
-            2 => '#5c8d20',# '#008800', #green'#55FF55',
219
+            2 => '#5c8d20', # '#008800', #green'#55FF55',
220 220
             3 => '#85eD82',
221 221
             4 => '#2E97E0', # blue
222 222
             5 => '#B9E3F9',
223
-            6 => '#e1711d',  # orange
223
+            6 => '#e1711d', # orange
224 224
             7 => '#ffc04c',
225 225
             8 => '#FDFF98', # yellow
226 226
             9 => '#5555FF',
227 227
             10 => '#55FFFF',
228
-            11 => '#0000C0',  #
229
-            12 => '#008800',  # green
228
+            11 => '#0000C0', #
229
+            12 => '#008800', # green
230 230
             13 => '#00C0C0',
231
-            14 => '#FFAFAF',  # rosé
232
-            15 => '#808080',  # gray
231
+            14 => '#FFAFAF', # rosé
232
+            15 => '#808080', # gray
233 233
             16 => '#00C000',
234 234
             17 => '#404040',
235
-            18 => '#C0C000',  # green
235
+            18 => '#C0C000', # green
236 236
             19 => '#C000C0',
237
-            100 => '#75A3D1',  # blue
238
-            101 => '#A679D2',  # purple
237
+            100 => '#75A3D1', # blue
238
+            101 => '#A679D2', # purple
239 239
             102 => '#660000',
240 240
             103 => '#000066',
241
-            104 => '#FAFFAF',  # caramel
241
+            104 => '#FAFFAF', # caramel
242 242
             105 => '#408345',
243 243
             106 => '#5c8d20',
244
-            107 => '#e1711d',  # red
245
-            108 => '#94ef2b',  # light green
246
-            109 => '#756a4a',  # brown
244
+            107 => '#e1711d', # red
245
+            108 => '#94ef2b', # light green
246
+            109 => '#756a4a', # brown
247 247
             110 => '#6f1dab',
248 248
             111 => '#301e30',
249 249
             112 => '#5c9d96',
250
-            113 => '#a8cd8c',  # earth green
251
-            114 => '#f2b3f1',  # light purple
250
+            113 => '#a8cd8c', # earth green
251
+            114 => '#f2b3f1', # light purple
252 252
             115 => '#9b5828',
253 253
             118 => '#99FFFF',
254 254
             119 => '#99BBFF',
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
             446 => '#06DCFB',
270 270
             447 => '#892EE4',
271 271
             460 => '#99FF66',
272
-            461 => '#99CC66',  # green
273
-            470 => '#CCCC33',  # ocker
272
+            461 => '#99CC66', # green
273
+            470 => '#CCCC33', # ocker
274 274
             471 => '#CCFF33',
275 275
             480 => '#6699FF',
276 276
             481 => '#66FFFF',
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
             1198 => '#FF34B3',
286 286
             1199 => '#8B1C62',
287 287
 
288
-            '#61a9f3',# blue
289
-            '#f381b9',# pink
288
+            '#61a9f3', # blue
289
+            '#f381b9', # pink
290 290
             '#61E3A9',
291 291
             '#D56DE2',
292 292
             '#85eD82',
293 293
             '#F7b7b7',
294 294
             '#CFDF49',
295 295
             '#88d8f2',
296
-            '#07AF7B',# green
296
+            '#07AF7B', # green
297 297
             '#B9E3F9',
298 298
             '#FFF3AD',
299
-            '#EF606A',# red
299
+            '#EF606A', # red
300 300
             '#EC8833',
301 301
             '#FFF100',
302 302
             '#87C9A5',
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
     public function getFilters()
414 414
     {
415 415
         return [
416
-            new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]),
416
+            new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']),
417 417
         ];
418 418
     }
419 419
 
Please login to merge, or discard this patch.
src/AppBundle/Controller/TopEditsController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                 'username' => $username,
49 49
             ]);
50 50
         } elseif ($project != "") {
51
-            return $this->redirectToRoute("TopEditsResults", [ 'project'=>$project ]);
51
+            return $this->redirectToRoute("TopEditsResults", ['project'=>$project]);
52 52
         }
53 53
 
54 54
         // set default wiki so we can populate the namespace selector
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             // show error message and redirect back to default project
67 67
             $this->addFlash("notice", [$e->getMessage()]);
68 68
             $project = $this->container->getParameter('default_project');
69
-            return $this->redirectToRoute("PagesProject", [ 'project'=>$project ]);
69
+            return $this->redirectToRoute("PagesProject", ['project'=>$project]);
70 70
         }
71 71
 
72 72
         return $this->render('topedits/index.html.twig', [
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         $editData = $conn->executeQuery($query, $params)->fetchAll();
120 120
 
121 121
         // Get page info about these 100 pages, so we can use their display title.
122
-        $titles = array_map(function ($e) {
122
+        $titles = array_map(function($e) {
123 123
             return $e['page_title'];
124 124
         }, $editData);
125 125
         /** @var ApiHelper $apiHelper */
Please login to merge, or discard this patch.
src/AppBundle/Controller/EditCounterController.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -6,13 +6,9 @@
 block discarded – undo
6 6
 use AppBundle\Helper\AutomatedEditsHelper;
7 7
 use AppBundle\Helper\EditCounterHelper;
8 8
 use AppBundle\Helper\LabsHelper;
9
-use Mediawiki\Api\ApiUser;
10 9
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
11 10
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12
-use Symfony\Component\DependencyInjection\ContainerInterface;
13 11
 use Symfony\Component\HttpFoundation\Request;
14
-use Symfony\Component\HttpFoundation\RequestStack;
15
-use Symfony\Component\VarDumper\VarDumper;
16 12
 
17 13
 class EditCounterController extends Controller
18 14
 {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
         $username = $request->query->get('username');
64 64
 
65 65
         if (($project || $queryProject) && $username) {
66
-            $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ];
66
+            $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username];
67 67
             return $this->redirectToRoute("EditCounterResult", $routeParams);
68 68
         } elseif (!$project && $queryProject) {
69
-            return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]);
69
+            return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]);
70 70
         }
71 71
 
72 72
         $this->init($project);
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
             'rev_small' => $revisionCounts['small'],
172 172
             'rev_large' => $revisionCounts['large'],
173 173
             'with_comments' => $revisionCounts['with_comments'],
174
-            'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'],
174
+            'without_comments' => $revisionCounts['live']-$revisionCounts['with_comments'],
175 175
             'minor_edits' => $revisionCounts['minor_edits'],
176
-            'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'],
176
+            'nonminor_edits' => $revisionCounts['live']-$revisionCounts['minor_edits'],
177 177
             'auto_edits_total' => array_sum($automatedEditsSummary),
178 178
 
179 179
             // Page counts.
Please login to merge, or discard this patch.