Completed
Pull Request — master (#45)
by
unknown
02:48
created
src/AppBundle/Controller/ApiController.php 1 patch
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -5,12 +5,8 @@
 block discarded – undo
5 5
 
6 6
 namespace AppBundle\Controller;
7 7
 
8
-use Exception;
9
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10 8
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11
-use Symfony\Component\HttpFoundation\Request;
12 9
 use Symfony\Component\HttpFoundation\Response;
13
-use Symfony\Component\Debug\Exception\FatalErrorException;
14 10
 use FOS\RestBundle\Controller\Annotations as Rest;
15 11
 use FOS\RestBundle\Controller\FOSRestController;
16 12
 use FOS\RestBundle\View\View;
Please login to merge, or discard this patch.
src/AppBundle/Controller/AutomatedEditsController.php 1 patch
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.
src/AppBundle/Helper/AutomatedEditsHelper.php 1 patch
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -5,9 +5,7 @@
 block discarded – undo
5 5
 
6 6
 namespace AppBundle\Helper;
7 7
 
8
-use DateTime;
9 8
 use Symfony\Component\DependencyInjection\ContainerInterface;
10
-use Xtools\ProjectRepository;
11 9
 
12 10
 /**
13 11
  * Helper class for getting information about semi-automated edits.
Please login to merge, or discard this patch.
src/Xtools/EditCounterRepository.php 1 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/Xtools/UserRepository.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         $this->stopwatch->start($cacheKey, 'XTools');
79 79
         $api = $this->getMediawikiApi($project);
80
-        $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ];
80
+        $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"];
81 81
         $query = new SimpleRequest('query', $params);
82 82
         $result = [];
83 83
         $res = $api->getRequest($query);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         // Create the API query.
114 114
         $api = $this->getMediawikiApi($project);
115
-        $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ];
115
+        $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"];
116 116
         $query = new SimpleRequest('query', $params);
117 117
 
118 118
         // Get the result.
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
     {
157 157
         $username = $user->getUsername();
158 158
 
159
-        $cacheKey = 'pages.' . $project->getDatabaseName() . '.'
160
-            . $user->getCacheKey() . '.' . $namespace . '.' . $redirects;
159
+        $cacheKey = 'pages.'.$project->getDatabaseName().'.'
160
+            . $user->getCacheKey().'.'.$namespace.'.'.$redirects;
161 161
         if ($this->cache->hasItem($cacheKey)) {
162 162
             return $this->cache->getItem($cacheKey)->get();
163 163
         }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             JOIN $revisionTable ON page_id = rev_page
216 216
             $paJoin
217 217
             WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition
218
-            " . ($hasPageAssessments ? 'GROUP BY rev_page' : '') . "
218
+            ".($hasPageAssessments ? 'GROUP BY rev_page' : '')."
219 219
             )
220 220
 
221 221
             UNION
@@ -262,21 +262,21 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function countEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '')
264 264
     {
265
-        $cacheKey = 'editcount.' . $project->getDatabaseName() . '.'
266
-            . $user->getCacheKey() . '.' . $namespace;
265
+        $cacheKey = 'editcount.'.$project->getDatabaseName().'.'
266
+            . $user->getCacheKey().'.'.$namespace;
267 267
 
268 268
         $condBegin = '';
269 269
         $condEnd = '';
270 270
 
271 271
         if (!empty($start)) {
272
-            $cacheKey .= '.' . $start;
272
+            $cacheKey .= '.'.$start;
273 273
 
274 274
             // For the query
275 275
             $start = date('Ymd000000', strtotime($start));
276 276
             $condBegin = 'AND rev_timestamp >= :start ';
277 277
         }
278 278
         if (!empty($end)) {
279
-            $cacheKey .= '.' . $end;
279
+            $cacheKey .= '.'.$end;
280 280
 
281 281
             // For the query
282 282
             $end = date('Ymd235959', strtotime($end));
@@ -335,21 +335,21 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function countAutomatedEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '')
337 337
     {
338
-        $cacheKey = 'autoeditcount.' . $project->getDatabaseName() . '.'
339
-            . $user->getCacheKey() . '.' . $namespace;
338
+        $cacheKey = 'autoeditcount.'.$project->getDatabaseName().'.'
339
+            . $user->getCacheKey().'.'.$namespace;
340 340
 
341 341
         $condBegin = '';
342 342
         $condEnd = '';
343 343
 
344 344
         if (!empty($start)) {
345
-            $cacheKey .= '.' . $start;
345
+            $cacheKey .= '.'.$start;
346 346
 
347 347
             // For the query
348 348
             $start = date('Ymd000000', strtotime($start));
349 349
             $condBegin = 'AND rev_timestamp >= :start ';
350 350
         }
351 351
         if (!empty($end)) {
352
-            $cacheKey .= '.' . $end;
352
+            $cacheKey .= '.'.$end;
353 353
 
354 354
             // For the query
355 355
             $end = date('Ymd235959', strtotime($end));
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 
364 364
         $conn = $this->getProjectsConnection();
365 365
         $tools = $this->container->getParameter('automated_tools');
366
-        $toolRegexes = array_map(function ($tool) {
366
+        $toolRegexes = array_map(function($tool) {
367 367
             return $tool['regex'];
368 368
         }, $tools);
369 369
         $regex = $conn->quote(implode('|', $toolRegexes), \PDO::PARAM_STR);
@@ -425,21 +425,21 @@  discard block
 block discarded – undo
425 425
         $end = '',
426 426
         $offset = 0
427 427
     ) {
428
-        $cacheKey = 'nonautoedits.' . $project->getDatabaseName() . '.'
429
-            . $user->getCacheKey() . '.' . $namespace . '.' . $offset;
428
+        $cacheKey = 'nonautoedits.'.$project->getDatabaseName().'.'
429
+            . $user->getCacheKey().'.'.$namespace.'.'.$offset;
430 430
 
431 431
         $condBegin = '';
432 432
         $condEnd = '';
433 433
 
434 434
         if (!empty($start)) {
435
-            $cacheKey .= '.' . $start;
435
+            $cacheKey .= '.'.$start;
436 436
 
437 437
             // For the query
438 438
             $start = date('Ymd000000', strtotime($start));
439 439
             $condBegin = 'AND revs.rev_timestamp >= :start ';
440 440
         }
441 441
         if (!empty($end)) {
442
-            $cacheKey .= '.' . $end;
442
+            $cacheKey .= '.'.$end;
443 443
 
444 444
             // For the query
445 445
             $end = date('Ymd235959', strtotime($end));
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 
456 456
         // Build regex for all semi-automated tools
457 457
         $tools = $this->container->getParameter('automated_tools');
458
-        $toolRegexes = array_map(function ($tool) {
458
+        $toolRegexes = array_map(function($tool) {
459 459
             return $tool['regex'];
460 460
         }, $tools);
461 461
         $regex = $conn->quote(implode('|', $toolRegexes), \PDO::PARAM_STR);
@@ -532,21 +532,21 @@  discard block
 block discarded – undo
532 532
         $start = '',
533 533
         $end = ''
534 534
     ) {
535
-        $cacheKey = 'autotoolcounts.' . $project->getDatabaseName() . '.'
536
-            . $user->getCacheKey() . '.' . $namespace;
535
+        $cacheKey = 'autotoolcounts.'.$project->getDatabaseName().'.'
536
+            . $user->getCacheKey().'.'.$namespace;
537 537
 
538 538
         $condBegin = '';
539 539
         $condEnd = '';
540 540
 
541 541
         if (!empty($start)) {
542
-            $cacheKey .= '.' . $start;
542
+            $cacheKey .= '.'.$start;
543 543
 
544 544
             // For the query
545 545
             $start = date('Ymd000000', strtotime($start));
546 546
             $condBegin = 'AND rev_timestamp >= :start ';
547 547
         }
548 548
         if (!empty($end)) {
549
-            $cacheKey .= '.' . $end;
549
+            $cacheKey .= '.'.$end;
550 550
 
551 551
             // For the query
552 552
             $end = date('Ymd235959', strtotime($end));
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
         }
625 625
 
626 626
         // Sort the array by count
627
-        uasort($results, function ($a, $b) {
628
-            return $b['count'] - $a['count'];
627
+        uasort($results, function($a, $b) {
628
+            return $b['count']-$a['count'];
629 629
         });
630 630
 
631 631
         // Cache for 10 minutes, and return.
Please login to merge, or discard this patch.
src/Xtools/User.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -206,21 +206,21 @@
 block discarded – undo
206 206
 
207 207
         $namespaces = $project->getNamespaces();
208 208
 
209
-        return array_map(function ($rev) use ($namespaces) {
209
+        return array_map(function($rev) use ($namespaces) {
210 210
             $pageTitle = $rev['page_title'];
211 211
 
212 212
             if ($rev['page_namespace'] !== '0') {
213
-                $pageTitle = $namespaces[$rev['page_namespace']] . ":$pageTitle";
213
+                $pageTitle = $namespaces[$rev['page_namespace']].":$pageTitle";
214 214
             }
215 215
 
216 216
             return [
217 217
                 'page_title' => $pageTitle,
218
-                'page_namespace' => (int) $rev['page_namespace'],
219
-                'rev_id' => (int) $rev['rev_id'],
218
+                'page_namespace' => (int)$rev['page_namespace'],
219
+                'rev_id' => (int)$rev['rev_id'],
220 220
                 'timestamp' => DateTime::createFromFormat('YmdHis', $rev['timestamp']),
221
-                'minor' => (bool) $rev['minor'],
222
-                'length' => (int) $rev['length'],
223
-                'length_change' => (int) $rev['length_change'],
221
+                'minor' => (bool)$rev['minor'],
222
+                'length' => (int)$rev['length'],
223
+                'length_change' => (int)$rev['length_change'],
224 224
                 'comment' => $rev['comment'],
225 225
             ];
226 226
         }, $revs);
Please login to merge, or discard this patch.