Completed
Pull Request — master (#15)
by Sam
03:18
created
var/SymfonyRequirements.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false)
51 51
     {
52
-        $this->fulfilled = (bool) $fulfilled;
53
-        $this->testMessage = (string) $testMessage;
54
-        $this->helpHtml = (string) $helpHtml;
55
-        $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText;
56
-        $this->optional = (bool) $optional;
52
+        $this->fulfilled = (bool)$fulfilled;
53
+        $this->testMessage = (string)$testMessage;
54
+        $this->helpHtml = (string)$helpHtml;
55
+        $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string)$helpText;
56
+        $this->optional = (bool)$optional;
57 57
     }
58 58
 
59 59
     /**
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
             );
545 545
         }
546 546
 
547
-        $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null;
547
+        $pcreVersion = defined('PCRE_VERSION') ? (float)PCRE_VERSION : null;
548 548
 
549 549
         $this->addRequirement(
550 550
             null !== $pcreVersion,
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
         $unit = '';
784 784
         if (!ctype_digit($size)) {
785 785
             $unit = strtolower(substr($size, -1, 1));
786
-            $size = (int) substr($size, 0, -1);
786
+            $size = (int)substr($size, 0, -1);
787 787
         }
788 788
         switch ($unit) {
789 789
             case 'g':
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
             case 'k':
794 794
                 return $size * 1024;
795 795
             default:
796
-                return (int) $size;
796
+                return (int)$size;
797 797
         }
798 798
     }
799 799
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
                 continue;
816 816
             }
817 817
 
818
-            return (int) $package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION;
818
+            return (int)$package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION;
819 819
         }
820 820
 
821 821
         return false;
Please login to merge, or discard this patch.
src/AppBundle/Controller/EditCounterController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
         $username = $request->query->get('user');
28 28
 
29 29
         if (($project || $queryProject) && $username) {
30
-            $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ];
30
+            $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username];
31 31
             return $this->redirectToRoute("EditCounterResult", $routeParams);
32 32
         } elseif (!$project && $queryProject) {
33
-            return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]);
33
+            return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]);
34 34
         }
35 35
 
36 36
         // Otherwise fall through.
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
             'rev_small' => $revisionCounts['small'],
106 106
             'rev_large' => $revisionCounts['large'],
107 107
             'with_comments' => $revisionCounts['with_comments'],
108
-            'without_comments' => $revisionCounts['live'] - $revisionCounts['with_comments'],
108
+            'without_comments' => $revisionCounts['live']-$revisionCounts['with_comments'],
109 109
             'minor_edits' => $revisionCounts['minor_edits'],
110
-            'nonminor_edits' => $revisionCounts['live'] - $revisionCounts['minor_edits'],
110
+            'nonminor_edits' => $revisionCounts['live']-$revisionCounts['minor_edits'],
111 111
 
112 112
             // Page counts.
113 113
             'uniquePages' => $pageCounts['unique'],
Please login to merge, or discard this patch.
src/AppBundle/Controller/ArticleInfoController.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
         $article = $request->query->get('article');
56 56
 
57 57
         if ($projectQuery != '' && $article != '') {
58
-            return $this->redirectToRoute('ArticleInfoResult', [ 'project'=>$projectQuery, 'article' => $article ]);
58
+            return $this->redirectToRoute('ArticleInfoResult', ['project'=>$projectQuery, 'article' => $article]);
59 59
         } elseif ($article != '') {
60
-            return $this->redirectToRoute('ArticleInfoProject', [ 'project'=>$projectQuery ]);
60
+            return $this->redirectToRoute('ArticleInfoProject', ['project'=>$projectQuery]);
61 61
         }
62 62
 
63 63
         return $this->render('articleInfo/index.html.twig', [
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             'url' => $basicInfo['fullurl']
102 102
         ];
103 103
 
104
-        $this->pageInfo['watchers'] = ( isset($basicInfo['watchers']) ) ? $basicInfo['watchers'] : "< 30";
104
+        $this->pageInfo['watchers'] = (isset($basicInfo['watchers'])) ? $basicInfo['watchers'] : "< 30";
105 105
 
106 106
         $pageProps = isset($basicInfo['pageprops']) ? $basicInfo['pageprops'] : [];
107 107
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function getRevCount()
165 165
     {
166
-        $query = "SELECT COUNT(*) AS count FROM " . $this->revisionTable
167
-                 . " WHERE rev_page = '" . $this->pageInfo['id'] . "'";
166
+        $query = "SELECT COUNT(*) AS count FROM ".$this->revisionTable
167
+                 . " WHERE rev_page = '".$this->pageInfo['id']."'";
168 168
         $res = $this->conn->query($query)->fetchAll();
169 169
         return $res[0]['count'];
170 170
     }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
                   FROM $this->revisionTable
197 197
                   LEFT JOIN $userGroupsTable ON rev_user = ug_user
198 198
                   LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user
199
-                  WHERE rev_page = " . $this->pageInfo['id'] . " AND (ug_group = 'bot' OR ufg_group = 'bot')
199
+                  WHERE rev_page = ".$this->pageInfo['id']." AND (ug_group = 'bot' OR ufg_group = 'bot')
200 200
                   GROUP BY rev_user_text";
201 201
         $res = $this->conn->query($query)->fetchAll();
202 202
 
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
         $sum = 0;
206 206
         foreach ($res as $bot) {
207 207
             $bots[$bot['username']] = [
208
-                'count' => (int) $bot['count'],
208
+                'count' => (int)$bot['count'],
209 209
                 'current' => $bot['current'] === 'bot'
210 210
             ];
211 211
             $sum += $bot['count'];
212 212
         }
213 213
 
214
-        uasort($bots, function ($a, $b) {
215
-            return $b['count'] - $a['count'];
214
+        uasort($bots, function($a, $b) {
215
+            return $b['count']-$a['count'];
216 216
         });
217 217
 
218 218
         $this->pageInfo['general']['bot_revision_count'] = $sum;
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
 
249 249
             if ($info['all'] > 1) {
250 250
                 // Number of seconds between first and last edit
251
-                $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']);
251
+                $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']);
252 252
 
253 253
                 // Average time between edits (in days)
254
-                $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 );
254
+                $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24);
255 255
             }
256 256
 
257 257
             if (count($info['sizes'])) {
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
         // Transform to associative array by 'type'
299 299
         foreach ($res as $row) {
300
-            $data[$row['type'] . '_count'] = $row['value'];
300
+            $data[$row['type'].'_count'] = $row['value'];
301 301
         }
302 302
 
303 303
         return $data;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $title = str_replace(' ', '_', $this->pageInfo['title']);
314 314
         $query = "SELECT log_action, log_type, log_timestamp AS timestamp
315 315
                   FROM $loggingTable
316
-                  WHERE log_namespace = '" . $this->pageInfo['namespace'] . "'
316
+                  WHERE log_namespace = '".$this->pageInfo['namespace']."'
317 317
                   AND log_title = '$title' AND log_timestamp > 1
318 318
                   AND log_type IN ('delete', 'move', 'protect', 'stable')";
319 319
         $events = $this->conn->query($query)->fetchAll();
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         $query = "SELECT rev_id, rev_parent_id, rev_user_text, rev_user, rev_timestamp,
372 372
                   rev_minor_edit, rev_len, rev_comment
373 373
                   FROM $this->revisionTable
374
-                  WHERE rev_page = '" . $this->pageInfo['id'] . "' AND rev_timestamp > 1
374
+                  WHERE rev_page = '".$this->pageInfo['id']."' AND rev_timestamp > 1
375 375
                   ORDER BY rev_timestamp";
376 376
 
377 377
         $res = $this->conn->query($query)->fetchAll();
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
             return $rev['rev_len'];
392 392
         }
393 393
 
394
-        $lastRev = $this->pageHistory[$revIndex - 1];
394
+        $lastRev = $this->pageHistory[$revIndex-1];
395 395
 
396
-        return $rev['rev_len'] - $lastRev['rev_len'];
396
+        return $rev['rev_len']-$lastRev['rev_len'];
397 397
     }
398 398
 
399 399
     /**
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
         // The month of the first edit. Used as a comparison when building the per-month data
414 414
         $firstEditMonth = strtotime(date('Y-m-01, 00:00', strtotime($firstEdit['rev_timestamp'])));
415 415
 
416
-        $lastEdit = $this->pageHistory[ $revisionCount - 1 ];
417
-        $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ];
416
+        $lastEdit = $this->pageHistory[$revisionCount-1];
417
+        $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2];
418 418
 
419 419
         // Now we can start our master array. This one will be HUGE!
420 420
         $lastEditSize = ($revisionCount > 1)
421
-            ? $lastEdit['rev_len'] - $secondLastEdit['rev_len']
421
+            ? $lastEdit['rev_len']-$secondLastEdit['rev_len']
422 422
             : $lastEdit['rev_len'];
423 423
         $data = [
424 424
             'general' => [
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
             // Increment year and month counts for all edits
516 516
             $data['year_count'][$timestamp['year']]['all']++;
517 517
             $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']++;
518
-            $data['year_count'][$timestamp['year']]['size'] = (int) $rev['rev_len'];
518
+            $data['year_count'][$timestamp['year']]['size'] = (int)$rev['rev_len'];
519 519
 
520 520
             $editsThisMonth = $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all'];
521 521
             if ($editsThisMonth > $data['max_edits_per_month']) {
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
                 }
560 560
 
561 561
                 // determine if the next revision was a revert
562
-                $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null;
562
+                $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null;
563 563
                 $nextRevisionIsRevert = $nextRevision &&
564
-                    $this->getDiffSize($i + 1) === -$diffSize &&
564
+                    $this->getDiffSize($i+1) === -$diffSize &&
565 565
                     $this->aeh->isRevert($nextRevision['rev_comment']);
566 566
 
567 567
                 // don't count this edit as content removal if the next edit reverted it
Please login to merge, or discard this patch.
src/AppBundle/Helper/ApiHelper.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     {
42 42
 
43 43
         $this->setUp($project);
44
-        $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ];
44
+        $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"];
45 45
         $query = new SimpleRequest('query', $params);
46 46
         $result = [];
47 47
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     {
62 62
 
63 63
         $this->setUp($project);
64
-        $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ];
64
+        $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"];
65 65
         $query = new SimpleRequest('query', $params);
66 66
         $result = [];
67 67
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
     public function namespaces($project)
87 87
     {
88 88
         // Use cache if possible.
89
-        $cacheItem = $this->cache->getItem('api.namespaces.' . $project);
89
+        $cacheItem = $this->cache->getItem('api.namespaces.'.$project);
90 90
         if ($cacheItem->isHit()) {
91 91
             return $cacheItem->get();
92 92
         }
93 93
 
94 94
         $this->setUp($project);
95
-        $query = new SimpleRequest('query', [ "meta"=>"siteinfo", "siprop"=>"namespaces" ]);
95
+        $query = new SimpleRequest('query', ["meta"=>"siteinfo", "siprop"=>"namespaces"]);
96 96
         $result = [];
97 97
 
98 98
         try {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             $normalized = [];
198 198
             if (isset($result['query']['normalized'])) {
199 199
                 array_map(
200
-                    function ($e) use (&$normalized) {
200
+                    function($e) use (&$normalized) {
201 201
                         $normalized[$e['to']] = $e['from'];
202 202
                     },
203 203
                     $result['query']['normalized']
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         ];
241 241
 
242 242
         // get assessments for this page from the API
243
-        $assessments = $this->massApi($params, $project, function ($data) {
243
+        $assessments = $this->massApi($params, $project, function($data) {
244 244
             return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : [];
245 245
         }, 'pacontinue')['pages'];
246 246
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                 $classAttrs = $config['class']['Unknown'];
268 268
                 $assessment['class']['value'] = '???';
269 269
                 $assessment['class']['category'] = $classAttrs['category'];
270
-                $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge'];
270
+                $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge'];
271 271
             } else {
272 272
                 $classAttrs = $config['class'][$classValue];
273 273
                 $assessment['class'] = [
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 
279 279
                 // add full URL to badge icon
280 280
                 if ($classAttrs['badge'] !== '') {
281
-                    $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" .
281
+                    $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".
282 282
                         $classAttrs['badge'];
283 283
                 }
284 284
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
         $query = FluentRequest::factory()->setAction('query')->setParams($requestData);
403 403
         $innerPromise = $this->api->getRequestAsync($query);
404 404
 
405
-        $innerPromise->then(function ($result) use (&$data) {
405
+        $innerPromise->then(function($result) use (&$data) {
406 406
             // some failures come back as 200s, so we still resolve and let the outer function handle it
407 407
             if (isset($result['error']) || !isset($result['query'])) {
408 408
                 return $data['promise']->resolve($data);
Please login to merge, or discard this patch.
src/AppBundle/Helper/LabsHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             // Create the query we're going to run against the meta database
63 63
             $wikiQuery = $this->client->createQueryBuilder();
64 64
             $wikiQuery
65
-                ->select([ 'dbName', 'name', 'url' ])
65
+                ->select(['dbName', 'name', 'url'])
66 66
                 ->from('wiki')
67 67
                 ->where($wikiQuery->expr()->eq('dbname', ':project'))
68 68
                 // 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 ];
103
+        return ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url];
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   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@  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('shortHash', [ $this, 'gitShortHash' ]),
33
-            new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]),
34
-            new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]),
35
-            new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]),
36
-            new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]),
37
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
38
-            new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]),
39
-            new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]),
40
-            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]),
41
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
42
-            new \Twig_SimpleFunction('replag', [ $this, 'replag' ]),
43
-            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('shortHash', [$this, 'gitShortHash']),
33
+            new \Twig_SimpleFunction('hash', [$this, 'gitHash']),
34
+            new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']),
35
+            new \Twig_SimpleFunction('tools', [$this, 'allTools']),
36
+            new \Twig_SimpleFunction('color', [$this, 'getColorList']),
37
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
38
+            new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']),
39
+            new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']),
40
+            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']),
41
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
42
+            new \Twig_SimpleFunction('replag', [$this, 'replag']),
43
+            new \Twig_SimpleFunction('link', [$this, 'link']),
44 44
         ];
45 45
     }
46 46
 
47 47
     public function requestTime($decimals = 3)
48 48
     {
49 49
 
50
-        return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals);
50
+        return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals);
51 51
     }
52 52
 
53 53
     public function requestMemory()
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function linkToWiki($url, $page, $secondary = "")
75 75
     {
76
-        $link = $url . "/";
76
+        $link = $url."/";
77 77
 
78 78
         if ($this->isWMFLabs()) {
79 79
             $link .= "wiki/";
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
     public function linkToWikiScript($url, $secondary)
92 92
     {
93
-        $link = $url . "/";
93
+        $link = $url."/";
94 94
 
95 95
         if ($this->isWMFLabs()) {
96 96
             $link .= "w/";
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     // TODO: refactor all intuition stuff so it can be used anywhere
107 107
     public function intuitionMessageExists($message = "")
108 108
     {
109
-        return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]);
109
+        return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]);
110 110
     }
111 111
 
112 112
     public function intuitionMessagePrintExists($message = "", $vars = [])
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function intuitionMessage($message = "", $vars = [])
127 127
     {
128
-        return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]);
128
+        return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]);
129 129
     }
130 130
 
131 131
     public function intuitionMessageFooter()
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
      */
154 154
     public function getAllLangs()
155 155
     {
156
-        $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json');
156
+        $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json');
157 157
 
158 158
         $languages = array_values(array_unique(array_map(
159
-            function ($filename) {
159
+            function($filename) {
160 160
                 return basename($filename, '.json');
161 161
             },
162 162
             $messageFiles
@@ -208,41 +208,41 @@  discard block
 block discarded – undo
208 208
     public static function getColorList($num = false)
209 209
     {
210 210
         $colors = [
211
-            0 => '#Cc0000',# '#FF005A', #red '#FF5555',
211
+            0 => '#Cc0000', # '#FF005A', #red '#FF5555',
212 212
             1 => '#F7b7b7',
213
-            2 => '#5c8d20',# '#008800', #green'#55FF55',
213
+            2 => '#5c8d20', # '#008800', #green'#55FF55',
214 214
             3 => '#85eD82',
215 215
             4 => '#2E97E0', # blue
216 216
             5 => '#B9E3F9',
217
-            6 => '#e1711d',  # orange
217
+            6 => '#e1711d', # orange
218 218
             7 => '#ffc04c',
219 219
             8 => '#FDFF98', # yellow
220 220
             9 => '#5555FF',
221 221
             10 => '#55FFFF',
222
-            11 => '#0000C0',  #
223
-            12 => '#008800',  # green
222
+            11 => '#0000C0', #
223
+            12 => '#008800', # green
224 224
             13 => '#00C0C0',
225
-            14 => '#FFAFAF',  # rosé
226
-            15 => '#808080',  # gray
225
+            14 => '#FFAFAF', # rosé
226
+            15 => '#808080', # gray
227 227
             16 => '#00C000',
228 228
             17 => '#404040',
229
-            18 => '#C0C000',  # green
229
+            18 => '#C0C000', # green
230 230
             19 => '#C000C0',
231
-            100 => '#75A3D1',  # blue
232
-            101 => '#A679D2',  # purple
231
+            100 => '#75A3D1', # blue
232
+            101 => '#A679D2', # purple
233 233
             102 => '#660000',
234 234
             103 => '#000066',
235
-            104 => '#FAFFAF',  # caramel
235
+            104 => '#FAFFAF', # caramel
236 236
             105 => '#408345',
237 237
             106 => '#5c8d20',
238
-            107 => '#e1711d',  # red
239
-            108 => '#94ef2b',  # light green
240
-            109 => '#756a4a',  # brown
238
+            107 => '#e1711d', # red
239
+            108 => '#94ef2b', # light green
240
+            109 => '#756a4a', # brown
241 241
             110 => '#6f1dab',
242 242
             111 => '#301e30',
243 243
             112 => '#5c9d96',
244
-            113 => '#a8cd8c',  # earth green
245
-            114 => '#f2b3f1',  # light purple
244
+            113 => '#a8cd8c', # earth green
245
+            114 => '#f2b3f1', # light purple
246 246
             115 => '#9b5828',
247 247
             118 => '#99FFFF',
248 248
             119 => '#99BBFF',
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
             446 => '#06DCFB',
264 264
             447 => '#892EE4',
265 265
             460 => '#99FF66',
266
-            461 => '#99CC66',  # green
267
-            470 => '#CCCC33',  # ocker
266
+            461 => '#99CC66', # green
267
+            470 => '#CCCC33', # ocker
268 268
             471 => '#CCFF33',
269 269
             480 => '#6699FF',
270 270
             481 => '#66FFFF',
@@ -279,18 +279,18 @@  discard block
 block discarded – undo
279 279
             1198 => '#FF34B3',
280 280
             1199 => '#8B1C62',
281 281
 
282
-            '#61a9f3',# blue
283
-            '#f381b9',# pink
282
+            '#61a9f3', # blue
283
+            '#f381b9', # pink
284 284
             '#61E3A9',
285 285
             '#D56DE2',
286 286
             '#85eD82',
287 287
             '#F7b7b7',
288 288
             '#CFDF49',
289 289
             '#88d8f2',
290
-            '#07AF7B',# green
290
+            '#07AF7B', # green
291 291
             '#B9E3F9',
292 292
             '#FFF3AD',
293
-            '#EF606A',# red
293
+            '#EF606A', # red
294 294
             '#EC8833',
295 295
             '#FFF100',
296 296
             '#87C9A5',
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     public function getFilters()
408 408
     {
409 409
         return [
410
-            new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]),
410
+            new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']),
411 411
         ];
412 412
     }
413 413
 
Please login to merge, or discard this patch.
src/AppBundle/Helper/EditCounterHelper.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     public function getUserId($usernameOrIp)
42 42
     {
43 43
         // Use cache if possible.
44
-        $cacheItem = $this->cache->getItem('ec.usernameOrIp.' . $usernameOrIp);
44
+        $cacheItem = $this->cache->getItem('ec.usernameOrIp.'.$usernameOrIp);
45 45
         if ($cacheItem->isHit()) {
46 46
             return $cacheItem->get();
47 47
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $topEditCounts = [];
72 72
         foreach ($this->labsHelper->allProjects() as $project) {
73
-            $cacheItem = $this->cache->getItem('editcounter.total.'.$project['dbName'].'.' . $username);
73
+            $cacheItem = $this->cache->getItem('editcounter.total.'.$project['dbName'].'.'.$username);
74 74
             if ($cacheItem->isHit()) {
75 75
                 // Use cache if possible.
76 76
                 $total = $cacheItem->get();
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
             }
90 90
             $topEditCounts[$project['dbName']] = array_merge($project, ['total' => $total]);
91 91
         }
92
-        uasort($topEditCounts, function ($a, $b) {
93
-            return $b['total'] - $a['total'];
92
+        uasort($topEditCounts, function($a, $b) {
93
+            return $b['total']-$a['total'];
94 94
         });
95 95
         return array_slice($topEditCounts, 0, $numProjects);
96 96
     }
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
         }
161 161
 
162 162
         $revisionCounts = array_combine(
163
-            array_map(function ($e) {
163
+            array_map(function($e) {
164 164
                 return $e['source'];
165 165
             }, $results),
166
-            array_map(function ($e) {
166
+            array_map(function($e) {
167 167
                 return $e['value'];
168 168
             }, $results)
169 169
         );
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
             : 0;
178 178
 
179 179
         // Count the number of days, accounting for when there's only one edit.
180
-        $editingTimeInSeconds = ceil($revisionCounts['last'] - $revisionCounts['first']);
181
-        $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds/(60*60*24) : 1;
180
+        $editingTimeInSeconds = ceil($revisionCounts['last']-$revisionCounts['first']);
181
+        $revisionCounts['days'] = $editingTimeInSeconds ? $editingTimeInSeconds / (60 * 60 * 24) : 1;
182 182
 
183 183
         // Sum deleted and live to make the total.
184
-        $revisionCounts['total'] = $revisionCounts['deleted'] + $revisionCounts['live'];
184
+        $revisionCounts['total'] = $revisionCounts['deleted']+$revisionCounts['live'];
185 185
         
186 186
         // Calculate the average number of live edits per day.
187 187
         $revisionCounts['avg_per_day'] = round(
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
         $results = $resultQuery->fetchAll();
223 223
 
224 224
         $pageCounts = array_combine(
225
-            array_map(function ($e) {
225
+            array_map(function($e) {
226 226
                 return $e['source'];
227 227
             }, $results),
228
-            array_map(function ($e) {
228
+            array_map(function($e) {
229 229
                 return $e['value'];
230 230
             }, $results)
231 231
         );
232 232
 
233 233
         // Total created.
234
-        $pageCounts['created'] = $pageCounts['created-live'] + $pageCounts['created-deleted'];
234
+        $pageCounts['created'] = $pageCounts['created-live']+$pageCounts['created-deleted'];
235 235
 
236 236
         // Calculate the average number of edits per page.
237 237
         $pageCounts['edits_per_page'] = 0;
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
         $resultQuery->execute();
259 259
         $results = $resultQuery->fetchAll();
260 260
         $logCounts = array_combine(
261
-            array_map(function ($e) {
261
+            array_map(function($e) {
262 262
                 return $e['source'];
263 263
             }, $results),
264
-            array_map(function ($e) {
264
+            array_map(function($e) {
265 265
                 return $e['value'];
266 266
             }, $results)
267 267
         );
268 268
 
269 269
         // Make sure there is some value for each of the wanted counts.
270 270
         $requiredCounts = [
271
-            'thanks-thank', 'review-approve', 'patrol-patrol','block-block', 'block-unblock',
271
+            'thanks-thank', 'review-approve', 'patrol-patrol', 'block-block', 'block-unblock',
272 272
             'protect-protect', 'protect-unprotect', 'delete-delete', 'delete-revision',
273 273
             'delete-restore', 'import-import', 'upload-upload', 'upload-overwrite',
274 274
         ];
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         // Merge approvals together.
282
-        $logCounts['review-approve'] = $logCounts['review-approve'] +
283
-            (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
284
-            (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
282
+        $logCounts['review-approve'] = $logCounts['review-approve']+
283
+            (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
284
+            (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
285 285
             (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
286 286
 
287 287
         // Add Commons upload count, if applicable.
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     public function getNamespaceTotals($userId)
307 307
     {
308 308
         $sql = "SELECT page_namespace, count(rev_id) AS total
309
-            FROM ".$this->labsHelper->getTable('revision') ." r
309
+            FROM ".$this->labsHelper->getTable('revision')." r
310 310
                 JOIN ".$this->labsHelper->getTable('page')." p on r.rev_page = p.page_id
311 311
             WHERE r.rev_user = :id GROUP BY page_namespace";
312 312
         $resultQuery = $this->replicas->prepare($sql);
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
         $resultQuery->execute();
315 315
         $results = $resultQuery->fetchAll();
316 316
         $namespaceTotals = array_combine(
317
-            array_map(function ($e) {
317
+            array_map(function($e) {
318 318
                 return $e['page_namespace'];
319 319
             }, $results),
320
-            array_map(function ($e) {
320
+            array_map(function($e) {
321 321
                 return $e['total'];
322 322
             }, $results)
323 323
         );
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
                 $sql =
343 343
                     "SELECT rev_id, rev_comment, rev_timestamp, rev_minor_edit, rev_deleted, "
344 344
                     . "     rev_len, rev_parent_id, page_title "
345
-                    . " FROM " . $this->labsHelper->getTable('revision', $project['dbName'])
346
-                    . "    JOIN " . $this->labsHelper->getTable('page', $project['dbName'])
345
+                    . " FROM ".$this->labsHelper->getTable('revision', $project['dbName'])
346
+                    . "    JOIN ".$this->labsHelper->getTable('page', $project['dbName'])
347 347
                     . "    ON (rev_page = page_id)"
348 348
                     . " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username"
349 349
                     . " ORDER BY rev_timestamp DESC"
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 continue;
361 361
             }
362 362
             $revsWithProject = array_map(
363
-                function (&$item) use ($project) {
363
+                function(&$item) use ($project) {
364 364
                     $item['project_name'] = $project['name'];
365 365
                     $item['project_url'] = $project['url'];
366 366
                     $item['project_db_name'] = $project['dbName'];
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
             );
371 371
             $allRevisions = array_merge($allRevisions, $revsWithProject);
372 372
         }
373
-        usort($allRevisions, function ($a, $b) {
374
-            return $b['rev_timestamp'] - $a['rev_timestamp'];
373
+        usort($allRevisions, function($a, $b) {
374
+            return $b['rev_timestamp']-$a['rev_timestamp'];
375 375
         });
376 376
         return array_slice($allRevisions, 0, $contribCount);
377 377
     }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
            . "     page_namespace,"
395 395
            . "     COUNT(rev_id) AS `count` "
396 396
            . " FROM ".$this->labsHelper->getTable('revision')
397
-           . "    JOIN " . $this->labsHelper->getTable('page')
397
+           . "    JOIN ".$this->labsHelper->getTable('page')
398 398
            . "    ON (rev_page = page_id)"
399 399
            . " WHERE rev_user_text = :username"
400 400
            . " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(6)), 1, 6), page_namespace "
@@ -456,10 +456,10 @@  discard block
 block discarded – undo
456 456
             . "     SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4) AS `year`,"
457 457
             . "     page_namespace,"
458 458
             . "     COUNT(rev_id) AS `count` "
459
-            . " FROM " . $this->labsHelper->getTable('revision')
460
-            . "    JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" .
461
-            " WHERE rev_user_text = :username" .
462
-            " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace " .
459
+            . " FROM ".$this->labsHelper->getTable('revision')
460
+            . "    JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)".
461
+            " WHERE rev_user_text = :username".
462
+            " GROUP BY SUBSTR(CAST(rev_timestamp AS CHAR(4)), 1, 4), page_namespace ".
463 463
             " ORDER BY rev_timestamp DESC ";
464 464
         $resultQuery = $this->replicas->prepare($sql);
465 465
         $resultQuery->bindParam(":username", $username);
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
             . "     DAYOFWEEK(rev_timestamp) AS `y`, "
495 495
             . "     $xCalc AS `x`, "
496 496
             . "     COUNT(rev_id) AS `r` "
497
-            . " FROM " . $this->labsHelper->getTable('revision')
497
+            . " FROM ".$this->labsHelper->getTable('revision')
498 498
             . " WHERE rev_user_text = :username"
499 499
             . " GROUP BY DAYOFWEEK(rev_timestamp), $xCalc "
500 500
             . " ";
Please login to merge, or discard this patch.