Completed
Pull Request — master (#102)
by Matthew
02:21
created
src/AppBundle/Controller/SimpleEditCounterController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
         // If we've got a project and user, redirect to results.
50 50
         if ($projectName != '' && $username != '') {
51
-            $routeParams = [ 'project' => $projectName, 'username' => $username ];
51
+            $routeParams = ['project' => $projectName, 'username' => $username];
52 52
             return $this->redirectToRoute('SimpleEditCounterResult', $routeParams);
53 53
         }
54 54
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
         $resultQuery->execute();
121 121
 
122 122
         if ($resultQuery->errorCode() > 0) {
123
-            $this->addFlash('notice', [ 'no-result', $username ]);
124
-            return $this->redirectToRoute('SimpleEditCounterProject', [ 'project' => $project->getDomain() ]);
123
+            $this->addFlash('notice', ['no-result', $username]);
124
+            return $this->redirectToRoute('SimpleEditCounterProject', ['project' => $project->getDomain()]);
125 125
         }
126 126
 
127 127
         // Fetch the result data
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
                 $rev = $row['value'];
146 146
             }
147 147
             if ($row['source'] == 'groups') {
148
-                $groups .= $row['value']. ', ';
148
+                $groups .= $row['value'].', ';
149 149
             }
150 150
         }
151 151
 
152 152
         // Unknown user - If the user is created the $results variable will have 3 entries.
153 153
         // This is a workaround to detect non-existent IPs.
154 154
         if (count($results) < 3 && $arch == 0 && $rev == 0) {
155
-            $this->addFlash('notice', [ 'no-result', $username ]);
155
+            $this->addFlash('notice', ['no-result', $username]);
156 156
 
157
-            return $this->redirectToRoute('SimpleEditCounterProject', [ 'project' => $project->getDomain() ]);
157
+            return $this->redirectToRoute('SimpleEditCounterProject', ['project' => $project->getDomain()]);
158 158
         }
159 159
 
160 160
         // Remove the last comma and space
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             'project' => $project,
184 184
             'id' => $id,
185 185
             'arch' => $arch,
186
-            'rev' => $rev + $arch,
186
+            'rev' => $rev+$arch,
187 187
             'live' => $rev,
188 188
             'groups' => $groups,
189 189
             'globalGroups' => $globalGroups,
Please login to merge, or discard this patch.
src/Xtools/Repository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
         // $tableExtension in order to generate the new table name
151 151
         if ($this->isLabs() && $tableExtension !== null) {
152 152
             $mapped = true;
153
-            $tableName = $tableName . '_' . $tableExtension;
153
+            $tableName = $tableName.'_'.$tableExtension;
154 154
         } elseif ($this->container->hasParameter("app.table.$tableName")) {
155 155
             // Use the table specified in the table mapping configuration, if present.
156 156
             $mapped = true;
Please login to merge, or discard this patch.
src/AppBundle/Controller/PagesController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
                 'username' => $username,
79 79
             ]);
80 80
         } elseif ($projectQuery != "") {
81
-            return $this->redirectToRoute("PagesProject", [ 'project'=>$projectQuery ]);
81
+            return $this->redirectToRoute("PagesProject", ['project'=>$projectQuery]);
82 82
         }
83 83
 
84 84
         // set default wiki so we can populate the namespace selector
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
         }
208 208
 
209 209
         if ($total < 1) {
210
-            $this->addFlash('notice', [ 'no-result', $username ]);
211
-            return $this->redirectToRoute('PagesProject', [ 'project' => $project ]);
210
+            $this->addFlash('notice', ['no-result', $username]);
211
+            return $this->redirectToRoute('PagesProject', ['project' => $project]);
212 212
         }
213 213
 
214 214
         ksort($pagesByNamespaceByDate);
Please login to merge, or discard this patch.
src/Xtools/EditCounterRepository.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
         $resultQuery->execute();
147 147
         $results = $resultQuery->fetchAll();
148 148
         $logCounts = array_combine(
149
-            array_map(function ($e) {
149
+            array_map(function($e) {
150 150
                 return $e['source'];
151 151
             }, $results),
152
-            array_map(function ($e) {
152
+            array_map(function($e) {
153 153
                 return $e['value'];
154 154
             }, $results)
155 155
         );
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
         $resultQuery->bindParam(":id", $userId);
367 367
         $resultQuery->execute();
368 368
         $results = $resultQuery->fetchAll();
369
-        $namespaceTotals = array_combine(array_map(function ($e) {
369
+        $namespaceTotals = array_combine(array_map(function($e) {
370 370
             return $e['page_namespace'];
371
-        }, $results), array_map(function ($e) {
371
+        }, $results), array_map(function($e) {
372 372
             return $e['total'];
373 373
         }, $results));
374 374
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
             }
428 428
             $queries[] = $sql;
429 429
         }
430
-        $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n";
430
+        $sql = "(\n".join("\n) UNION (\n", $queries).")\n";
431 431
         $resultQuery = $this->getProjectsConnection()->prepare($sql);
432 432
         $resultQuery->bindParam(":username", $username);
433 433
         $resultQuery->execute();
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
 namespace Xtools;
7 7
 
8 8
 use DateInterval;
9
-use DateTime;
10 9
 use Mediawiki\Api\SimpleRequest;
11 10
 
12 11
 /**
Please login to merge, or discard this patch.
src/AppBundle/Controller/AutomatedEditsController.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 use Symfony\Component\HttpFoundation\Request;
12 12
 use Symfony\Component\HttpFoundation\Response;
13 13
 use Xtools\ProjectRepository;
14
-use Xtools\User;
15 14
 use Xtools\UserRepository;
16 15
 
17 16
 /**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             'xtSubtitle' => 'tool-autoedits-desc',
87 87
             'xtPage' => 'autoedits',
88 88
             'project' => $project,
89
-            'namespace' => (int) $namespace,
89
+            'namespace' => (int)$namespace,
90 90
             'start' => $startDate,
91 91
             'end' => $endDate,
92 92
         ]);
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
         // Get individual counts of how many times each tool was used.
158 158
         // This also includes a wikilink to the tool.
159 159
         $toolCounts = $user->getAutomatedCounts($projectData, $namespace, $start, $end);
160
-        $toolsTotal = array_reduce($toolCounts, function ($a, $b) {
161
-            return $a + $b['count'];
160
+        $toolsTotal = array_reduce($toolCounts, function($a, $b) {
161
+            return $a+$b['count'];
162 162
         });
163 163
 
164 164
         // Query to get combined (semi)automated using for all edits
Please login to merge, or discard this patch.
src/AppBundle/Controller/EditSummaryController.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,6 @@
 block discarded – undo
10 10
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11 11
 use Symfony\Component\HttpFoundation\Request;
12 12
 use Symfony\Component\HttpFoundation\Response;
13
-use Psr\Cache\CacheItemPoolInterface;
14 13
 use Xtools\Project;
15 14
 use Xtools\ProjectRepository;
16 15
 use Xtools\User;
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@
 block discarded – undo
102 102
      *
103 103
      * @param string $project  The project domain name.
104 104
      * @param string $username The username.
105
-     * @param string $namespace Namespace ID or 'all' for all namespaces.
105
+     * @param integer $namespace Namespace ID or 'all' for all namespaces.
106 106
      *
107 107
      * @Route("/editsummary/{project}/{username}/{namespace}", name="EditSummaryResult")
108 108
      *
Please login to merge, or discard this patch.
Spacing   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                 'xtSubtitle' => 'tool-es-desc',
93 93
                 'xtPage' => 'es',
94 94
                 'project' => $theProject,
95
-                'namespace' => (int) $namespace,
95
+                'namespace' => (int)$namespace,
96 96
             ]
97 97
         );
98 98
     }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     {
159 159
         $dbName = $project->getDatabaseName();
160 160
 
161
-        $cacheKey = 'editsummaryusage.' . $dbName . '.'
162
-            . $user->getCacheKey() . '.' . $namespace;
161
+        $cacheKey = 'editsummaryusage.'.$dbName.'.'
162
+            . $user->getCacheKey().'.'.$namespace;
163 163
 
164 164
         $cache = $this->container->get('cache.app');
165 165
         if ($cache->hasItem($cacheKey)) {
@@ -246,8 +246,7 @@  discard block
 block discarded – undo
246 246
             if ($row['rev_minor_edit'] == 0) {
247 247
                 if ($row['rev_comment'] !== '') {
248 248
                     isset($monthEditsummaryTotals[$monthkey]) ?
249
-                        $monthEditsummaryTotals[$monthkey]++ :
250
-                        $monthEditsummaryTotals[$monthkey] = 1;
249
+                        $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1;
251 250
                     $totalSummariesMajor++;
252 251
                 }
253 252
 
@@ -264,8 +263,7 @@  discard block
 block discarded – undo
264 263
                 // If there is a comment, count it
265 264
                 if ($row['rev_comment'] !== '') {
266 265
                     isset($monthEditsummaryTotals[$monthkey]) ?
267
-                        $monthEditsummaryTotals[$monthkey]++ :
268
-                        $monthEditsummaryTotals[$monthkey] = 1;
266
+                        $monthEditsummaryTotals[$monthkey]++ : $monthEditsummaryTotals[$monthkey] = 1;
269 267
                     $totalSummariesMinor++;
270 268
                     $totalEditsMinor++;
271 269
                 } else {
Please login to merge, or discard this patch.
src/AppBundle/Helper/AutomatedEditsHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function isAutomated($summary, $projectDomain)
59 59
     {
60
-        return (bool) $this->getTool($summary, $projectDomain);
60
+        return (bool)$this->getTool($summary, $projectDomain);
61 61
     }
62 62
 
63 63
     /**
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 
110 110
         $revertEntries = array_filter(
111 111
             $this->getTools($projectDomain),
112
-            function ($tool) {
112
+            function($tool) {
113 113
                 return isset($tool['revert']);
114 114
             }
115 115
         );
116 116
 
117 117
         // If 'revert' is set to `true`, the use 'regex' as the regular expression,
118 118
         //  otherwise 'revert' is assumed to be the regex string.
119
-        $this->revertTools[$projectDomain] = array_map(function ($revertTool) {
119
+        $this->revertTools[$projectDomain] = array_map(function($revertTool) {
120 120
             return [
121 121
                 'link' => $revertTool['link'],
122 122
                 'regex' => $revertTool['revert'] === true ? $revertTool['regex'] : $revertTool['revert']
Please login to merge, or discard this patch.
src/Xtools/Edit.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
         $this->page = $page;
50 50
 
51 51
         // Copy over supported attributes
52
-        $this->id = (int) $attrs['id'];
52
+        $this->id = (int)$attrs['id'];
53 53
 
54 54
         // Allow DateTime or string (latter assumed to be of format YmdHis)
55 55
         if ($attrs['timestamp'] instanceof DateTime) {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $isSection = preg_match_all("/^\/\* (.*?) \*\//", $summary, $sectionMatch);
199 199
 
200 200
         if ($isSection) {
201
-            $pageUrl = $this->getProject()->getUrl(false) . str_replace(
201
+            $pageUrl = $this->getProject()->getUrl(false).str_replace(
202 202
                 '$1',
203 203
                 $this->getPage()->getTitle(),
204 204
                 $this->getProject()->getArticlePath()
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
             // Must have underscores for the link to properly go to the section
209 209
             $sectionTitleLink = htmlspecialchars(str_replace(' ', '_', $sectionTitle));
210 210
 
211
-            $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>&rarr;</a>" .
212
-                "<em class='text-muted'>" . htmlspecialchars($sectionTitle) . ":</em> ";
211
+            $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>&rarr;</a>".
212
+                "<em class='text-muted'>".htmlspecialchars($sectionTitle).":</em> ";
213 213
             $summary = str_replace($sectionMatch[0][0], $sectionWikitext, $summary);
214 214
         }
215 215
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
             );
224 224
 
225 225
             // Use normalized page title (underscored, capitalized)
226
-            $pageUrl = $this->getProject()->getUrl(false) . str_replace(
226
+            $pageUrl = $this->getProject()->getUrl(false).str_replace(
227 227
                 '$1',
228 228
                 ucfirst(str_replace(' ', '_', $wikiLinkPath)),
229 229
                 $this->getProject()->getArticlePath()
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
     public function getDiffUrl()
262 262
     {
263 263
         $project = $this->getProject();
264
-        $path = str_replace('$1', 'Special:Diff/' . $this->id, $project->getArticlePath());
265
-        return rtrim($project->getUrl(), '/') . $path;
264
+        $path = str_replace('$1', 'Special:Diff/'.$this->id, $project->getArticlePath());
265
+        return rtrim($project->getUrl(), '/').$path;
266 266
     }
267 267
 
268 268
     /**
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
     public function getPermaUrl()
273 273
     {
274 274
         $project = $this->getProject();
275
-        $path = str_replace('$1', 'Special:PermaLink/' . $this->id, $project->getArticlePath());
276
-        return rtrim($project->getUrl(), '/') . $path;
275
+        $path = str_replace('$1', 'Special:PermaLink/'.$this->id, $project->getArticlePath());
276
+        return rtrim($project->getUrl(), '/').$path;
277 277
     }
278 278
 
279 279
     /**
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public function isAutomated(Container $container)
307 307
     {
308
-        return (bool) $this->getTool($container);
308
+        return (bool)$this->getTool($container);
309 309
     }
310 310
 
311 311
     /**
Please login to merge, or discard this patch.
src/AppBundle/Controller/RfXVoteCalculatorController.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,6 @@
 block discarded – undo
3 3
 namespace AppBundle\Controller;
4 4
 
5 5
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
-use Symfony\Component\CssSelector\Exception\InternalErrorException;
7
-use Symfony\Component\Debug\Exception\ContextErrorException;
8 6
 use Symfony\Component\HttpFoundation\Request;
9 7
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10 8
 use Xtools\ProjectRepository;
Please login to merge, or discard this 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 = $request->query->get('username');
49 49
 
50 50
         if ($projectQuery != '' && $username != '') {
51
-            $routeParams = [ 'project' => $projectQuery, 'username' => $username ];
51
+            $routeParams = ['project' => $projectQuery, 'username' => $username];
52 52
             return $this->redirectToRoute(
53 53
                 'rfxvoteResult',
54 54
                 $routeParams
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
             $titles = [];
168 168
 
169 169
             while ($row = $sth->fetch()) {
170
-                $titles[] = $namespaces[$row['page_namespace']] .
171
-                    ':' .$row['page_title'];
170
+                $titles[] = $namespaces[$row['page_namespace']].
171
+                    ':'.$row['page_title'];
172 172
             }
173 173
 
174 174
             // Chunking... it's possible to make a URI too long
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @Route("/rfxvote/index.php", name="rfxvoteIndexPhp")
40 40
      * @Route("/rfxvote", name="RfXVoteCalculator")
41 41
      *
42
-     * @return Response
42
+     * @return \Symfony\Component\HttpFoundation\Response
43 43
      */
44 44
     public function indexAction()
45 45
     {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @Route("/rfxvote/{project}/{username}", name="rfxvoteResult")
90 90
      *
91
-     * @return Response
91
+     * @return \Symfony\Component\HttpFoundation\Response
92 92
      */
93 93
     public function resultAction($project, $username)
94 94
     {
Please login to merge, or discard this patch.