Completed
Push — master ( 5e33bb...9a10b7 )
by Sam
03:35
created
src/Xtools/PagesRepository.php 1 patch
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
      * @param Project $project The project to which the page belongs.
16 16
      * @param string $pageTitle Page title.
17 17
      * @param boolean $followRedirects Whether or not to resolve redirects
18
-     * @return string[] Array with some of the following keys: pageid, title, missing, displaytitle,
18
+     * @return string|null Array with some of the following keys: pageid, title, missing, displaytitle,
19 19
      * url.
20 20
      */
21 21
     public function getPageInfo(Project $project, $pageTitle, $followRedirects = true)
@@ -63,9 +63,8 @@  discard block
 block discarded – undo
63 63
 
64 64
     /**
65 65
      * Get revisions of a single page.
66
-     * @param Project $project
67 66
      * @param Page $page
68
-     * @param User|null $user
67
+     * @param User $user
69 68
      * @return string[] Each member with keys: id, timestamp, length-
70 69
      */
71 70
     public function getRevisions(Page $page, User $user)
Please login to merge, or discard this patch.
src/AppBundle/Twig/AppExtension.php 1 patch
Spacing   +57 added lines, -57 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('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options),
23
-            new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options),
24
-            new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options),
25
-            new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options),
26
-            new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options),
27
-            new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]),
28
-            new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]),
29
-            new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]),
30
-            new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]),
31
-            new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]),
32
-            new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]),
33
-            new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]),
34
-            new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]),
35
-            new \Twig_SimpleFunction('chartColor', [ $this, 'chartColor' ]),
36
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
37
-            new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]),
38
-            new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]),
39
-            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]),
40
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
41
-            new \Twig_SimpleFunction('replag', [ $this, 'replag' ]),
42
-            new \Twig_SimpleFunction('link', [ $this, 'link' ]),
43
-            new \Twig_SimpleFunction('quote', [ $this, 'quote' ]),
44
-            new \Twig_SimpleFunction('bugReportURL', [ $this, 'bugReportURL' ]),
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('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options),
23
+            new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options),
24
+            new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options),
25
+            new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options),
26
+            new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options),
27
+            new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']),
28
+            new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']),
29
+            new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']),
30
+            new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']),
31
+            new \Twig_SimpleFunction('hash', [$this, 'gitHash']),
32
+            new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']),
33
+            new \Twig_SimpleFunction('tools', [$this, 'allTools']),
34
+            new \Twig_SimpleFunction('color', [$this, 'getColorList']),
35
+            new \Twig_SimpleFunction('chartColor', [$this, 'chartColor']),
36
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
37
+            new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']),
38
+            new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']),
39
+            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']),
40
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
41
+            new \Twig_SimpleFunction('replag', [$this, 'replag']),
42
+            new \Twig_SimpleFunction('link', [$this, 'link']),
43
+            new \Twig_SimpleFunction('quote', [$this, 'quote']),
44
+            new \Twig_SimpleFunction('bugReportURL', [$this, 'bugReportURL']),
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()
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     // TODO: refactor all intuition stuff so it can be used anywhere
69 69
     public function intuitionMessageExists($message = "")
70 70
     {
71
-        return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]);
71
+        return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]);
72 72
     }
73 73
 
74 74
     public function intuitionMessagePrintExists($message = "", $vars = [])
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
     public function intuitionMessage($message = "", $vars = [])
89 89
     {
90
-        return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]);
90
+        return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]);
91 91
     }
92 92
 
93 93
     public function getLang()
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function getAllLangs()
110 110
     {
111
-        $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json');
111
+        $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json');
112 112
 
113 113
         $languages = array_values(array_unique(array_map(
114
-            function ($filename) {
114
+            function($filename) {
115 115
                 return basename($filename, '.json');
116 116
             },
117 117
             $messageFiles
@@ -168,41 +168,41 @@  discard block
 block discarded – undo
168 168
     public static function getColorList($num = false)
169 169
     {
170 170
         $colors = [
171
-            0 => '#Cc0000',# '#FF005A', #red '#FF5555',
171
+            0 => '#Cc0000', # '#FF005A', #red '#FF5555',
172 172
             1 => '#F7b7b7',
173
-            2 => '#5c8d20',# '#008800', #green'#55FF55',
173
+            2 => '#5c8d20', # '#008800', #green'#55FF55',
174 174
             3 => '#85eD82',
175 175
             4 => '#2E97E0', # blue
176 176
             5 => '#B9E3F9',
177
-            6 => '#e1711d',  # orange
177
+            6 => '#e1711d', # orange
178 178
             7 => '#ffc04c',
179 179
             8 => '#FDFF98', # yellow
180 180
             9 => '#5555FF',
181 181
             10 => '#55FFFF',
182
-            11 => '#0000C0',  #
183
-            12 => '#008800',  # green
182
+            11 => '#0000C0', #
183
+            12 => '#008800', # green
184 184
             13 => '#00C0C0',
185
-            14 => '#FFAFAF',  # rosé
186
-            15 => '#808080',  # gray
185
+            14 => '#FFAFAF', # rosé
186
+            15 => '#808080', # gray
187 187
             16 => '#00C000',
188 188
             17 => '#404040',
189
-            18 => '#C0C000',  # green
189
+            18 => '#C0C000', # green
190 190
             19 => '#C000C0',
191
-            100 => '#75A3D1',  # blue
192
-            101 => '#A679D2',  # purple
191
+            100 => '#75A3D1', # blue
192
+            101 => '#A679D2', # purple
193 193
             102 => '#660000',
194 194
             103 => '#000066',
195
-            104 => '#FAFFAF',  # caramel
195
+            104 => '#FAFFAF', # caramel
196 196
             105 => '#408345',
197 197
             106 => '#5c8d20',
198
-            107 => '#e1711d',  # red
199
-            108 => '#94ef2b',  # light green
200
-            109 => '#756a4a',  # brown
198
+            107 => '#e1711d', # red
199
+            108 => '#94ef2b', # light green
200
+            109 => '#756a4a', # brown
201 201
             110 => '#6f1dab',
202 202
             111 => '#301e30',
203 203
             112 => '#5c9d96',
204
-            113 => '#a8cd8c',  # earth green
205
-            114 => '#f2b3f1',  # light purple
204
+            113 => '#a8cd8c', # earth green
205
+            114 => '#f2b3f1', # light purple
206 206
             115 => '#9b5828',
207 207
             118 => '#99FFFF',
208 208
             119 => '#99BBFF',
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
             446 => '#06DCFB',
224 224
             447 => '#892EE4',
225 225
             460 => '#99FF66',
226
-            461 => '#99CC66',  # green
227
-            470 => '#CCCC33',  # ocker
226
+            461 => '#99CC66', # green
227
+            470 => '#CCCC33', # ocker
228 228
             471 => '#CCFF33',
229 229
             480 => '#6699FF',
230 230
             481 => '#66FFFF',
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
             1198 => '#FF34B3',
240 240
             1199 => '#8B1C62',
241 241
 
242
-            '#61a9f3',# blue
243
-            '#f381b9',# pink
242
+            '#61a9f3', # blue
243
+            '#f381b9', # pink
244 244
             '#61E3A9',
245 245
             '#D56DE2',
246 246
             '#85eD82',
247 247
             '#F7b7b7',
248 248
             '#CFDF49',
249 249
             '#88d8f2',
250
-            '#07AF7B',# green
250
+            '#07AF7B', # green
251 251
             '#B9E3F9',
252 252
             '#FFF3AD',
253
-            '#EF606A',# red
253
+            '#EF606A', # red
254 254
             '#EC8833',
255 255
             '#FFF100',
256 256
             '#87C9A5',
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
     public function getFilters()
401 401
     {
402 402
         return [
403
-            new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]),
404
-            new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]),
403
+            new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']),
404
+            new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']),
405 405
         ];
406 406
     }
407 407
 
@@ -428,9 +428,9 @@  discard block
 block discarded – undo
428 428
         if (!$denominator) {
429 429
             $quotient = $numerator;
430 430
         } else {
431
-            $quotient = ( $numerator / $denominator ) * 100;
431
+            $quotient = ($numerator / $denominator) * 100;
432 432
         }
433 433
 
434
-        return round($quotient, $precision) . '%';
434
+        return round($quotient, $precision).'%';
435 435
     }
436 436
 }
Please login to merge, or discard this patch.
src/AppBundle/Helper/AutomatedEditsHelper.php 2 patches
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -3,12 +3,7 @@
 block discarded – undo
3 3
 namespace AppBundle\Helper;
4 4
 
5 5
 use DateTime;
6
-use Doctrine\DBAL\Connection;
7
-use Psr\Cache\CacheItemPoolInterface;
8
-use Symfony\Component\Config\Definition\Exception\Exception;
9
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
10 6
 use Symfony\Component\DependencyInjection\ContainerInterface;
11
-use Symfony\Component\VarDumper\VarDumper;
12 7
 use Xtools\ProjectRepository;
13 8
 
14 9
 class AutomatedEditsHelper extends HelperBase
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
         $editData = $conn->executeQuery($query, ['username' => $username])->fetchAll();
140 140
 
141 141
         // Get diff sizes, based on length of each parent revision
142
-        $parentRevIds = array_map(function ($edit) {
142
+        $parentRevIds = array_map(function($edit) {
143 143
             return $edit['rev_parent_id'];
144 144
         }, $editData);
145 145
         $query = "SELECT rev_len, rev_id
146 146
                   FROM revision
147
-                  WHERE rev_id IN (" . implode(',', $parentRevIds) . ")";
147
+                  WHERE rev_id IN (" . implode(',', $parentRevIds).")";
148 148
         $diffSizeData = $conn->executeQuery($query)->fetchAll();
149 149
 
150 150
         // reformat with rev_id as the key, rev_len as the value
@@ -154,24 +154,24 @@  discard block
 block discarded – undo
154 154
         }
155 155
 
156 156
         // Build our array of nonautomated edits
157
-        $editData = array_map(function ($edit) use ($namespaces, $diffSizes) {
157
+        $editData = array_map(function($edit) use ($namespaces, $diffSizes) {
158 158
             $pageTitle = $edit['page_title'];
159 159
 
160 160
             if ($edit['page_namespace'] !== '0') {
161
-                $pageTitle = $namespaces[$edit['page_namespace']] . ":$pageTitle";
161
+                $pageTitle = $namespaces[$edit['page_namespace']].":$pageTitle";
162 162
             }
163 163
 
164 164
             $diffSize = $edit['rev_len'];
165 165
             if ($edit['rev_parent_id'] > 0) {
166
-                $diffSize = $edit['rev_len'] - $diffSizes[$edit['rev_parent_id']];
166
+                $diffSize = $edit['rev_len']-$diffSizes[$edit['rev_parent_id']];
167 167
             }
168 168
 
169 169
             return [
170 170
                 'page_title' => $pageTitle,
171
-                'namespace' => (int) $edit['page_namespace'],
172
-                'rev_id' => (int) $edit['rev_id'],
171
+                'namespace' => (int)$edit['page_namespace'],
172
+                'rev_id' => (int)$edit['rev_id'],
173 173
                 'timestamp' => DateTime::createFromFormat('YmdHis', $edit['rev_timestamp']),
174
-                'minor_edit' => (bool) $edit['rev_minor_edit'],
174
+                'minor_edit' => (bool)$edit['rev_minor_edit'],
175 175
                 'summary' => $edit['rev_comment'],
176 176
                 'size' => $diffSize
177 177
             ];
Please login to merge, or discard this patch.
src/Xtools/UserRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
         $this->stopwatch->start($cacheKey, 'XTools');
62 62
         $api = $this->getMediawikiApi($project);
63
-        $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ];
63
+        $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"];
64 64
         $query = new SimpleRequest('query', $params);
65 65
         $result = [];
66 66
         $res = $api->getRequest($query);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
         // Create the API query.
98 98
         $api = $this->getMediawikiApi($project);
99
-        $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ];
99
+        $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"];
100 100
         $query = new SimpleRequest('query', $params);
101 101
 
102 102
         // Get the result.
Please login to merge, or discard this patch.
src/Xtools/EditCounter.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace Xtools;
4 4
 
5 5
 use \DateTime;
6
-use Symfony\Component\VarDumper\VarDumper;
7 6
 
8 7
 /**
9 8
  * An EditCounter provides statistics about a user's edits on a project.
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     protected function getRevisionCounts()
43 43
     {
44
-        if (! is_array($this->revisionCounts)) {
44
+        if (!is_array($this->revisionCounts)) {
45 45
             $this->revisionCounts = $this->getRepository()
46 46
                 ->getRevisionCounts($this->project, $this->user);
47 47
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     protected function getRevisionDates()
56 56
     {
57
-        if (! is_array($this->revisionDates)) {
57
+        if (!is_array($this->revisionDates)) {
58 58
             $this->revisionDates = $this->getRepository()
59 59
                 ->getRevisionDates($this->project, $this->user);
60 60
         }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     protected function getPageCounts()
69 69
     {
70
-        if (! is_array($this->pageCounts)) {
70
+        if (!is_array($this->pageCounts)) {
71 71
             $this->pageCounts = $this->getRepository()
72 72
                 ->getPageCounts($this->project, $this->user);
73 73
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function getLogCounts()
82 82
     {
83
-        if (! is_array($this->logCounts)) {
83
+        if (!is_array($this->logCounts)) {
84 84
             $this->logCounts = $this->getRepository()
85 85
                 ->getLogCounts($this->project, $this->user);
86 86
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function countAllRevisions()
111 111
     {
112
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
112
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
113 113
     }
114 114
 
115 115
     /**
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function countRevisionsWithoutComments()
130 130
     {
131
-        return $this->countAllRevisions() - $this->countRevisionsWithComments();
131
+        return $this->countAllRevisions()-$this->countRevisionsWithComments();
132 132
     }
133 133
 
134 134
     /**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public function countAllPagesEdited()
197 197
     {
198
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
198
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
199 199
     }
200 200
 
201 201
     /**
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function countPagesCreated()
215 215
     {
216
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
216
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
217 217
     }
218 218
 
219 219
     /**
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
     public function approvals()
360 360
     {
361 361
         $logCounts = $this->getLogCounts();
362
-        $total = $logCounts['review-approve'] +
363
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
364
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
362
+        $total = $logCounts['review-approve']+
363
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
364
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
365 365
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
366 366
         return $total;
367 367
     }
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
         // Get counts.
388 388
         $editCounts = $this->getRepository()->getRevisionCountsAllProjects($user, $project);
389 389
         // Sort.
390
-        uasort($editCounts, function ($a, $b) {
391
-            return $b['total'] - $a['total'];
390
+        uasort($editCounts, function($a, $b) {
391
+            return $b['total']-$a['total'];
392 392
         });
393 393
         // Truncate, and return.
394 394
         return array_slice($editCounts, 0, $numProjects);
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
@@ -2,13 +2,9 @@
 block discarded – undo
2 2
 
3 3
 namespace AppBundle\Controller;
4 4
 
5
-use AppBundle\Helper\ApiHelper;
6
-use AppBundle\Helper\AutomatedEditsHelper;
7
-use AppBundle\Helper\LabsHelper;
8 5
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9 6
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10 7
 use Symfony\Component\HttpFoundation\Request;
11
-use Symfony\Component\VarDumper\VarDumper;
12 8
 use Xtools\EditCounter;
13 9
 use Xtools\EditCounterRepository;
14 10
 use Xtools\Project;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,10 +65,10 @@
 block discarded – undo
65 65
         $username = $request->query->get('username');
66 66
 
67 67
         if (($project || $queryProject) && $username) {
68
-            $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ];
68
+            $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username];
69 69
             return $this->redirectToRoute("EditCounterResult", $routeParams);
70 70
         } elseif (!$project && $queryProject) {
71
-            return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]);
71
+            return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]);
72 72
         }
73 73
 
74 74
         $project = ProjectRepository::getProject($queryProject, $this->container);
Please login to merge, or discard this patch.
src/Xtools/EditCounterRepository.php 2 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -249,7 +249,6 @@  discard block
 block discarded – undo
249 249
      * Get a user's total edit count on one or more project.
250 250
      * Requires the CentralAuth extension to be installed on the project.
251 251
      *
252
-     * @param string $username The username.
253 252
      * @param Project $project The project to start from.
254 253
      * @return mixed[]|boolean Array of total edit counts, or false if none could be found.
255 254
      */
@@ -296,7 +295,7 @@  discard block
 block discarded – undo
296 295
 
297 296
     /**
298 297
      * Get total edit counts for the top 10 projects for this user.
299
-     * @param string $username The username.
298
+     * @param string $stopwatchName
300 299
      * @return string[] Elements are arrays with 'dbName', 'url', 'name', and 'total'.
301 300
      */
302 301
     protected function getRevisionCountsAllProjectsNoCentralAuth(
@@ -459,7 +458,6 @@  discard block
 block discarded – undo
459 458
 
460 459
     /**
461 460
      * Get yearly edit totals for this user, grouped by namespace.
462
-     * @param string $username
463 461
      * @return string[] ['<namespace>' => ['<year>' => 'total', ... ], ... ]
464 462
      */
465 463
     public function getYearCounts(Project $project, User $user)
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
     public function getRevisionCounts(Project $project, User $user)
18 18
     {
19 19
         // Set up cache.
20
-        $cacheKey = 'revisioncounts.' . $project->getDatabaseName() . '.' . $user->getUsername();
20
+        $cacheKey = 'revisioncounts.'.$project->getDatabaseName().'.'.$user->getUsername();
21 21
         if ($this->cache->hasItem($cacheKey)) {
22 22
             return $this->cache->getItem($cacheKey)->get();
23 23
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function getRevisionDates(Project $project, User $user)
79 79
     {
80 80
         // Set up cache.
81
-        $cacheKey = 'revisiondates.' . $project->getDatabaseName() . '.' . $user->getUsername();
81
+        $cacheKey = 'revisiondates.'.$project->getDatabaseName().'.'.$user->getUsername();
82 82
         if ($this->cache->hasItem($cacheKey)) {
83 83
             return $this->cache->getItem($cacheKey)->get();
84 84
         }
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
         $results = $resultQuery->fetchAll();
151 151
 
152 152
         $pageCounts = array_combine(
153
-            array_map(function ($e) {
153
+            array_map(function($e) {
154 154
                 return $e['source'];
155 155
             }, $results),
156
-            array_map(function ($e) {
156
+            array_map(function($e) {
157 157
                 return $e['value'];
158 158
             }, $results)
159 159
         );
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
         // Query.
186 186
         $sql = "SELECT CONCAT(log_type, '-', log_action) AS source, COUNT(log_id) AS value
187
-            FROM " . $this->getTableName($project->getDatabaseName(), 'logging') . "
187
+            FROM " . $this->getTableName($project->getDatabaseName(), 'logging')."
188 188
             WHERE log_user = :userId
189 189
             GROUP BY log_type, log_action";
190 190
         $resultQuery = $this->getProjectsConnection()->prepare($sql);
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
         $resultQuery->execute();
194 194
         $results = $resultQuery->fetchAll();
195 195
         $logCounts = array_combine(
196
-            array_map(function ($e) {
196
+            array_map(function($e) {
197 197
                 return $e['source'];
198 198
             }, $results),
199
-            array_map(function ($e) {
199
+            array_map(function($e) {
200 200
                 return $e['value'];
201 201
             }, $results)
202 202
         );
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
         $resultQuery->bindParam(":id", $userId);
343 343
         $resultQuery->execute();
344 344
         $results = $resultQuery->fetchAll();
345
-        $namespaceTotals = array_combine(array_map(function ($e) {
345
+        $namespaceTotals = array_combine(array_map(function($e) {
346 346
             return $e['page_namespace'];
347
-        }, $results), array_map(function ($e) {
347
+        }, $results), array_map(function($e) {
348 348
             return $e['total'];
349 349
         }, $results));
350 350
         return $namespaceTotals;
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
                 $revisions = $this->cacheGet($cacheKey);
367 367
             } else {
368 368
                 $sql =
369
-                    "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, " .
370
-                    " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, " .
371
-                    " page_title, page_namespace " . " FROM " .
372
-                    $this->labsHelper->getTable('revision', $project['dbName']) . "    JOIN " .
373
-                    $this->labsHelper->getTable('page', $project['dbName']) .
374
-                    "    ON (rev_page = page_id)" .
375
-                    " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username" .
376
-                    " ORDER BY rev_timestamp DESC" . " LIMIT 10";
369
+                    "SELECT rev_id, rev_timestamp, UNIX_TIMESTAMP(rev_timestamp) AS unix_timestamp, ".
370
+                    " rev_minor_edit, rev_deleted, rev_len, rev_parent_id, rev_comment, ".
371
+                    " page_title, page_namespace "." FROM ".
372
+                    $this->labsHelper->getTable('revision', $project['dbName'])."    JOIN ".
373
+                    $this->labsHelper->getTable('page', $project['dbName']).
374
+                    "    ON (rev_page = page_id)".
375
+                    " WHERE rev_timestamp > NOW() - INTERVAL $days DAY AND rev_user_text LIKE :username".
376
+                    " ORDER BY rev_timestamp DESC"." LIMIT 10";
377 377
                 $resultQuery = $this->replicas->prepare($sql);
378 378
                 $resultQuery->bindParam(":username", $username);
379 379
                 $resultQuery->execute();
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             if (count($revisions) === 0) {
384 384
                 continue;
385 385
             }
386
-            $revsWithProject = array_map(function (&$item) use ($project) {
386
+            $revsWithProject = array_map(function(&$item) use ($project) {
387 387
                 $item['project_name'] = $project['wikiName'];
388 388
                 $item['project_url'] = $project['url'];
389 389
                 $item['project_db_name'] = $project['dbName'];
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
             }, $revisions);
394 394
             $allRevisions = array_merge($allRevisions, $revsWithProject);
395 395
         }
396
-        usort($allRevisions, function ($a, $b) {
397
-            return $b['rev_timestamp'] - $a['rev_timestamp'];
396
+        usort($allRevisions, function($a, $b) {
397
+            return $b['rev_timestamp']-$a['rev_timestamp'];
398 398
         });
399 399
 
400 400
         return array_slice($allRevisions, 0, $topN);
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
         }
414 414
 
415 415
         $sql =
416
-            "SELECT " . "     YEAR(rev_timestamp) AS `year`," .
417
-            "     MONTH(rev_timestamp) AS `month`," . "     page_namespace," .
418
-            "     COUNT(rev_id) AS `count` " . " FROM " . $this->labsHelper->getTable('revision') .
419
-            "    JOIN " . $this->labsHelper->getTable('page') . " ON (rev_page = page_id)" .
420
-            " WHERE rev_user_text = :username" .
421
-            " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace " .
416
+            "SELECT "."     YEAR(rev_timestamp) AS `year`,".
417
+            "     MONTH(rev_timestamp) AS `month`,"."     page_namespace,".
418
+            "     COUNT(rev_id) AS `count` "." FROM ".$this->labsHelper->getTable('revision').
419
+            "    JOIN ".$this->labsHelper->getTable('page')." ON (rev_page = page_id)".
420
+            " WHERE rev_user_text = :username".
421
+            " GROUP BY YEAR(rev_timestamp), MONTH(rev_timestamp), page_namespace ".
422 422
             " ORDER BY rev_timestamp DESC";
423 423
         $resultQuery = $this->replicas->prepare($sql);
424 424
         $resultQuery->bindParam(":username", $username);
@@ -440,14 +440,14 @@  discard block
 block discarded – undo
440 440
             if (!isset($out['totals'][$ns])) {
441 441
                 $out['totals'][$ns] = [];
442 442
             }
443
-            $out['totals'][$ns][$total['year'] . $total['month']] = $total['count'];
443
+            $out['totals'][$ns][$total['year'].$total['month']] = $total['count'];
444 444
         }
445 445
         // Fill in the blanks (where no edits were made in a given month for a namespace).
446 446
         for ($y = $out['min_year']; $y <= $out['max_year']; $y++) {
447 447
             for ($m = 1; $m <= 12; $m++) {
448 448
                 foreach ($out['totals'] as $nsId => &$total) {
449
-                    if (!isset($total[$y . $m])) {
450
-                        $total[$y . $m] = 0;
449
+                    if (!isset($total[$y.$m])) {
450
+                        $total[$y.$m] = 0;
451 451
                     }
452 452
                 }
453 453
             }
Please login to merge, or discard this patch.