Completed
Push — master ( 213592...bdf5df )
by Matthew
13:39 queued 01:37
created
src/Xtools/UserRepository.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
         $this->stopwatch->start($cacheKey, 'XTools');
80 80
         $api = $this->getMediawikiApi($project);
81
-        $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ];
81
+        $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"];
82 82
         $query = new SimpleRequest('query', $params);
83 83
         $result = [];
84 84
         $res = $api->getRequest($query);
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
         // Create the API query.
115 115
         $api = $this->getMediawikiApi($project);
116
-        $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ];
116
+        $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"];
117 117
         $query = new SimpleRequest('query', $params);
118 118
 
119 119
         // Get the result.
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $username = $user->getUsername();
159 159
 
160
-        $cacheKey = 'pages.' . $project->getDatabaseName() . '.'
161
-            . $user->getCacheKey() . '.' . $namespace . '.' . $redirects;
160
+        $cacheKey = 'pages.'.$project->getDatabaseName().'.'
161
+            . $user->getCacheKey().'.'.$namespace.'.'.$redirects;
162 162
         if ($this->cache->hasItem($cacheKey)) {
163 163
             return $this->cache->getItem($cacheKey)->get();
164 164
         }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             JOIN $revisionTable ON page_id = rev_page
217 217
             $paJoin
218 218
             WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition
219
-            " . ($hasPageAssessments ? 'GROUP BY rev_page' : '') . "
219
+            ".($hasPageAssessments ? 'GROUP BY rev_page' : '')."
220 220
             )
221 221
 
222 222
             UNION
@@ -263,21 +263,21 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function countEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '')
265 265
     {
266
-        $cacheKey = 'editcount.' . $project->getDatabaseName() . '.'
267
-            . $user->getCacheKey() . '.' . $namespace;
266
+        $cacheKey = 'editcount.'.$project->getDatabaseName().'.'
267
+            . $user->getCacheKey().'.'.$namespace;
268 268
 
269 269
         $condBegin = '';
270 270
         $condEnd = '';
271 271
 
272 272
         if (!empty($start)) {
273
-            $cacheKey .= '.' . $start;
273
+            $cacheKey .= '.'.$start;
274 274
 
275 275
             // For the query
276 276
             $start = date('Ymd000000', strtotime($start));
277 277
             $condBegin = 'AND rev_timestamp >= :start ';
278 278
         }
279 279
         if (!empty($end)) {
280
-            $cacheKey .= '.' . $end;
280
+            $cacheKey .= '.'.$end;
281 281
 
282 282
             // For the query
283 283
             $end = date('Ymd235959', strtotime($end));
@@ -337,21 +337,21 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function countAutomatedEdits(Project $project, User $user, $namespace = 'all', $start = '', $end = '')
339 339
     {
340
-        $cacheKey = 'autoeditcount.' . $project->getDatabaseName() . '.'
341
-            . $user->getCacheKey() . '.' . $namespace;
340
+        $cacheKey = 'autoeditcount.'.$project->getDatabaseName().'.'
341
+            . $user->getCacheKey().'.'.$namespace;
342 342
 
343 343
         $condBegin = '';
344 344
         $condEnd = '';
345 345
 
346 346
         if (!empty($start)) {
347
-            $cacheKey .= '.' . $start;
347
+            $cacheKey .= '.'.$start;
348 348
 
349 349
             // For the query
350 350
             $start = date('Ymd000000', strtotime($start));
351 351
             $condBegin = 'AND rev_timestamp >= :start ';
352 352
         }
353 353
         if (!empty($end)) {
354
-            $cacheKey .= '.' . $end;
354
+            $cacheKey .= '.'.$end;
355 355
 
356 356
             // For the query
357 357
             $end = date('Ymd235959', strtotime($end));
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             $tagJoin = $tags != '' ? "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id" : '';
384 384
             $condTools[] = "ct_tag IN ($tags)";
385 385
         }
386
-        $condTool = 'AND (' . implode(' OR ', $condTools) . ')';
386
+        $condTool = 'AND ('.implode(' OR ', $condTools).')';
387 387
 
388 388
         $sql = "SELECT COUNT(DISTINCT(rev_id))
389 389
                 FROM $revisionTable
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
             $resultQuery->bindParam('namespace', $namespace);
409 409
         }
410 410
         $resultQuery->execute();
411
-        $result = (int) $resultQuery->fetchColumn();
411
+        $result = (int)$resultQuery->fetchColumn();
412 412
 
413 413
         // Cache for 10 minutes, and return.
414 414
         $cacheItem = $this->cache->getItem($cacheKey)
@@ -440,21 +440,21 @@  discard block
 block discarded – undo
440 440
         $end = '',
441 441
         $offset = 0
442 442
     ) {
443
-        $cacheKey = 'nonautoedits.' . $project->getDatabaseName() . '.'
444
-            . $user->getCacheKey() . '.' . $namespace . '.' . $offset;
443
+        $cacheKey = 'nonautoedits.'.$project->getDatabaseName().'.'
444
+            . $user->getCacheKey().'.'.$namespace.'.'.$offset;
445 445
 
446 446
         $condBegin = '';
447 447
         $condEnd = '';
448 448
 
449 449
         if (!empty($start)) {
450
-            $cacheKey .= '.' . $start;
450
+            $cacheKey .= '.'.$start;
451 451
 
452 452
             // For the query
453 453
             $start = date('Ymd000000', strtotime($start));
454 454
             $condBegin = 'AND revs.rev_timestamp >= :start ';
455 455
         }
456 456
         if (!empty($end)) {
457
-            $cacheKey .= '.' . $end;
457
+            $cacheKey .= '.'.$end;
458 458
 
459 459
             // For the query
460 460
             $end = date('Ymd235959', strtotime($end));
@@ -547,21 +547,21 @@  discard block
 block discarded – undo
547 547
         $start = '',
548 548
         $end = ''
549 549
     ) {
550
-        $cacheKey = 'autotoolcounts.' . $project->getDatabaseName() . '.'
551
-            . $user->getCacheKey() . '.' . $namespace;
550
+        $cacheKey = 'autotoolcounts.'.$project->getDatabaseName().'.'
551
+            . $user->getCacheKey().'.'.$namespace;
552 552
 
553 553
         $condBegin = '';
554 554
         $condEnd = '';
555 555
 
556 556
         if (!empty($start)) {
557
-            $cacheKey .= '.' . $start;
557
+            $cacheKey .= '.'.$start;
558 558
 
559 559
             // For the query
560 560
             $start = date('Ymd000000', strtotime($start));
561 561
             $condBegin = 'AND rev_timestamp >= :start ';
562 562
         }
563 563
         if (!empty($end)) {
564
-            $cacheKey .= '.' . $end;
564
+            $cacheKey .= '.'.$end;
565 565
 
566 566
             // For the query
567 567
             $end = date('Ymd235959', strtotime($end));
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
                 if ($condTool === '') {
609 609
                     $condTool = "ct_tag = $tag";
610 610
                 } else {
611
-                    $condTool = '(' . $condTool . " OR ct_tag = $tag)";
611
+                    $condTool = '('.$condTool." OR ct_tag = $tag)";
612 612
                 }
613 613
             }
614 614
 
615 615
             // Developer error, no regex or tag provided for this tool.
616 616
             if ($condTool === '') {
617
-                throw new Exception("No regex or tag found for the tool $toolname. " .
617
+                throw new Exception("No regex or tag found for the tool $toolname. ".
618 618
                     "Please verify this entry in semi_automated.yml");
619 619
             }
620 620
 
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
         }
667 667
 
668 668
         // Sort the array by count
669
-        uasort($results, function ($a, $b) {
670
-            return $b['count'] - $a['count'];
669
+        uasort($results, function($a, $b) {
670
+            return $b['count']-$a['count'];
671 671
         });
672 672
 
673 673
         // Cache for 10 minutes, and return.
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * Get the user's (system) edit count.
97 97
      * @param string $databaseName The database to query.
98 98
      * @param string $username The username to find.
99
-     * @return int|null As returned by the database.
99
+     * @return string|boolean As returned by the database.
100 100
      */
101 101
     public function getEditCount($databaseName, $username)
102 102
     {
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
      * Get the combined regex and tags for all semi-automated tools,
742 742
      *   ready to be used in a query.
743 743
      * @param string $projectDomain Such as en.wikipedia.org
744
-     * @param $conn Doctrine\DBAL\Connection Used for proper escaping
744
+     * @param \Doctrine\DBAL\Connection $conn Doctrine\DBAL\Connection Used for proper escaping
745 745
      * @return string[] In the format:
746 746
      *    ['combined|regex', 'combined,tags']
747 747
      */
Please login to merge, or discard this patch.
src/Xtools/EditCounter.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
     /**
475 475
      * Get the date and time of the user's first edit.
476
-     * @return DateTime|bool The time of the first revision, or false.
476
+     * @return DateInterval The time of the first revision, or false.
477 477
      */
478 478
     public function datetimeFirstRevision()
479 479
     {
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 
484 484
     /**
485 485
      * Get the date and time of the user's first edit.
486
-     * @return DateTime|bool The time of the last revision, or false.
486
+     * @return DateInterval The time of the last revision, or false.
487 487
      */
488 488
     public function datetimeLastRevision()
489 489
     {
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 DateTime;
9
-use Exception;
10 9
 use DatePeriod;
11 10
 use DateInterval;
12 11
 use GuzzleHttp;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
             $promises[] = $promise;
118 118
 
119 119
             // Handle response of $promise asynchronously.
120
-            $promise->then(function ($response) use ($key, $endpoint) {
121
-                $result = (array) json_decode($response->getBody()->getContents());
120
+            $promise->then(function($response) use ($key, $endpoint) {
121
+                $result = (array)json_decode($response->getBody()->getContents());
122 122
 
123 123
                 if (isset($result)) {
124 124
                     // Copy result to the class class instance. From here any subsequent
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                     // We'll log this to see how often it happens.
132 132
                     $this->getRepository()
133 133
                         ->getLog()
134
-                        ->error("Failed to fetch data for $endpoint via async, " .
134
+                        ->error("Failed to fetch data for $endpoint via async, ".
135 135
                             "re-attempting synchoronously.");
136 136
                 }
137 137
             });
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
         // Filter out unblocks unless requested.
189 189
         if ($blocksOnly) {
190
-            $blocks = array_filter($blocks, function ($block) {
190
+            $blocks = array_filter($blocks, function($block) {
191 191
                 return $block['log_action'] === 'block';
192 192
             });
193 193
         }
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      */
222 222
     public function countAllRevisions()
223 223
     {
224
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
224
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
225 225
     }
226 226
 
227 227
     /**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
      */
241 241
     public function countRevisionsWithoutComments()
242 242
     {
243
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
243
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
244 244
     }
245 245
 
246 246
     /**
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function countAllPagesEdited()
281 281
     {
282
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
282
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
283 283
     }
284 284
 
285 285
     /**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function countPagesCreated()
291 291
     {
292
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
292
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
293 293
     }
294 294
 
295 295
     /**
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             } elseif ($block['log_action'] === 'unblock') {
430 430
                 // The last block was lifted. So the duration will be the time from when the
431 431
                 // last block was set to the time of the unblock.
432
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
432
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
433 433
                 if ($timeSinceLastBlock > $this->longestBlockSeconds) {
434 434
                     $this->longestBlockSeconds = $timeSinceLastBlock;
435 435
 
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
                 // The last block was modified. So we will adjust $lastBlock to include
441 441
                 // the difference of the duration of the new reblock, and time since the last block.
442 442
                 // $lastBlock is left unchanged if its duration was indefinite.
443
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
444
-                $lastBlock[1] = $timeSinceLastBlock + $duration;
443
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
444
+                $lastBlock[1] = $timeSinceLastBlock+$duration;
445 445
             }
446 446
         }
447 447
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
         }
452 452
 
453 453
         // Test if the last block is still active, and if so use the expiry as the duration.
454
-        $lastBlockExpiry = $lastBlock[0] + $lastBlock[1];
454
+        $lastBlockExpiry = $lastBlock[0]+$lastBlock[1];
455 455
         if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) {
456 456
             $this->longestBlockSeconds = $lastBlock[1];
457 457
         // Otherwise, test if the duration of the last block is now the longest overall.
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
         // If invalid, $duration is left as null.
493 493
         if (strtotime($durationStr)) {
494 494
             $expiry = strtotime($durationStr, $timestamp);
495
-            $duration = $expiry - $timestamp;
495
+            $duration = $expiry-$timestamp;
496 496
         }
497 497
 
498 498
         return [$timestamp, $duration];
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
570 570
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
571 571
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
572
-        return $import + $interwiki + $upload;
572
+        return $import+$interwiki+$upload;
573 573
     }
574 574
 
575 575
     /**
@@ -693,9 +693,9 @@  discard block
 block discarded – undo
693 693
     public function approvals()
694 694
     {
695 695
         $logCounts = $this->getLogCounts();
696
-        $total = $logCounts['review-approve'] +
697
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
698
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
696
+        $total = $logCounts['review-approve']+
697
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
698
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
699 699
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
700 700
         return $total;
701 701
     }
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
         $logCounts = $this->getLogCounts();
720 720
         $create2 = $logCounts['newusers-create2'] ?: 0;
721 721
         $byemail = $logCounts['newusers-byemail'] ?: 0;
722
-        return $create2 + $byemail;
722
+        return $create2+$byemail;
723 723
     }
724 724
 
725 725
     /**
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 
772 772
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
773 773
         $out = [
774
-            'yearLabels' => [],  // labels for years
774
+            'yearLabels' => [], // labels for years
775 775
             'monthLabels' => [], // labels for months
776 776
             'totals' => [], // actual totals, grouped by namespace, year and then month
777 777
         ];
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
                 $out['totals'][$ns][$total['year']] = [];
800 800
             }
801 801
 
802
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
802
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
803 803
         }
804 804
 
805 805
         $dateRange = new DatePeriod(
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
         );
810 810
 
811 811
         foreach ($dateRange as $monthObj) {
812
-            $year = (int) $monthObj->format('Y');
813
-            $month = (int) $monthObj->format('n');
812
+            $year = (int)$monthObj->format('Y');
813
+            $month = (int)$monthObj->format('n');
814 814
 
815 815
             // Fill in labels
816 816
             $out['monthLabels'][] = $monthObj->format('Y-m');
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 
927 927
         if ($sorted) {
928 928
             // Sort.
929
-            uasort($this->globalEditCounts, function ($a, $b) {
930
-                return $b['total'] - $a['total'];
929
+            uasort($this->globalEditCounts, function($a, $b) {
930
+                return $b['total']-$a['total'];
931 931
             });
932 932
         }
933 933
 
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
964 964
             }
965 965
             $page = $project->getRepository()
966
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
966
+                ->getPage($project, $nsName.':'.$revision['page_title']);
967 967
             $edit = new Edit($page, $revision);
968 968
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
969 969
         }
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
     public function countSmallEdits()
1005 1005
     {
1006 1006
         $editSizeData = $this->getEditSizeData();
1007
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
1007
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
1008 1008
     }
1009 1009
 
1010 1010
     /**
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
     public function countLargeEdits()
1015 1015
     {
1016 1016
         $editSizeData = $this->getEditSizeData();
1017
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
1017
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
1018 1018
     }
1019 1019
 
1020 1020
     /**
Please login to merge, or discard this patch.
src/AppBundle/Controller/ApiController.php 2 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -5,12 +5,9 @@
 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 9
 use Symfony\Component\HttpFoundation\Request;
12 10
 use Symfony\Component\HttpFoundation\Response;
13
-use Symfony\Component\Debug\Exception\FatalErrorException;
14 11
 use FOS\RestBundle\Controller\Annotations as Rest;
15 12
 use FOS\RestBundle\Controller\FOSRestController;
16 13
 use FOS\RestBundle\View\View;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $view = View::create()->setStatusCode(Response::HTTP_OK);
169 169
 
170 170
         if ($request->query->get('format') === 'html') {
171
-            $edits = array_map(function ($attrs) use ($project, $username) {
171
+            $edits = array_map(function($attrs) use ($project, $username) {
172 172
                 $page = $project->getRepository()
173 173
                     ->getPage($project, $attrs['full_page_title']);
174 174
                 $pageTitles[] = $attrs['full_page_title'];
@@ -244,19 +244,19 @@  discard block
 block discarded – undo
244 244
         $info = $page->getBasicEditingInfo();
245 245
         $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']);
246 246
         $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']);
247
-        $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp();
247
+        $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp();
248 248
 
249 249
         $data = [
250
-            'revisions' => (int) $info['num_edits'],
251
-            'editors' => (int) $info['num_editors'],
250
+            'revisions' => (int)$info['num_edits'],
251
+            'editors' => (int)$info['num_editors'],
252 252
             'author' => $info['author'],
253
-            'author_editcount' => (int) $info['author_editcount'],
253
+            'author_editcount' => (int)$info['author_editcount'],
254 254
             'created_at' => $creationDateTime->format('Y-m-d'),
255 255
             'created_rev_id' => $info['created_rev_id'],
256 256
             'modified_at' => $modifiedDateTime->format('Y-m-d H:i'),
257 257
             'secs_since_last_edit' => $secsSinceLastEdit,
258
-            'last_edit_id' => (int) $info['modified_rev_id'],
259
-            'watchers' => (int) $page->getWatchers(),
258
+            'last_edit_id' => (int)$info['modified_rev_id'],
259
+            'watchers' => (int)$page->getWatchers(),
260 260
             'pageviews' => $page->getLastPageviews($pageviewsOffset),
261 261
             'pageviews_offset' => $pageviewsOffset,
262 262
         ];
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         }
315 315
 
316 316
         $conn = $this->getDoctrine()->getManager('default')->getConnection();
317
-        $date =  date('Y-m-d');
317
+        $date = date('Y-m-d');
318 318
 
319 319
         // Increment count in timeline
320 320
         $existsSql = "SELECT 1 FROM usage_timeline
Please login to merge, or discard this patch.
src/Xtools/Page.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     /**
61 61
      * Get this page's database ID.
62
-     * @return int
62
+     * @return \string|null
63 63
      */
64 64
     public function getId()
65 65
     {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
     /**
71 71
      * Get this page's length in bytes.
72
-     * @return int
72
+     * @return \string|null
73 73
      */
74 74
     public function getLength()
75 75
     {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
     /**
95 95
      * Get the full URL of this page.
96
-     * @return string
96
+     * @return \string|null
97 97
      */
98 98
     public function getUrl()
99 99
     {
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
     /**
105 105
      * Get the numerical ID of the namespace of this page.
106
-     * @return int
106
+     * @return \string|null
107 107
      */
108 108
     public function getNamespace()
109 109
     {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
     /**
115 115
      * Get the number of page watchers.
116
-     * @return int
116
+     * @return \string|null
117 117
      */
118 118
     public function getWatchers()
119 119
     {
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 
421 421
     /**
422 422
      * Get the sum of pageviews for the given page and timeframe.
423
-     * @param string|DateTime $start In the format YYYYMMDD
424
-     * @param string|DateTime $end In the format YYYYMMDD
423
+     * @param string $start In the format YYYYMMDD
424
+     * @param string $end In the format YYYYMMDD
425 425
      * @return string[]
426 426
      */
427 427
     public function getPageviews($start, $end)
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $info = $this->getPageInfo();
82 82
         $title = isset($info['title']) ? $info['title'] : $this->unnormalizedPageName;
83 83
         $nsName = $this->getNamespaceName();
84
-        return str_replace($nsName . ':', '', $title);
84
+        return str_replace($nsName.':', '', $title);
85 85
     }
86 86
 
87 87
     /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     {
218 218
         // If a user is given, we will not cache the result via instance variable.
219 219
         if ($user !== null) {
220
-            return (int) $this->getRepository()->getNumRevisions($this, $user);
220
+            return (int)$this->getRepository()->getNumRevisions($this, $user);
221 221
         }
222 222
 
223 223
         // Return cached value, if present.
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
             $this->numRevisions = count($this->revisions);
231 231
         } else {
232 232
             // Otherwise do a COUNT in the event fetching all revisions is not desired.
233
-            $this->numRevisions = (int) $this->getRepository()->getNumRevisions($this);
233
+            $this->numRevisions = (int)$this->getRepository()->getNumRevisions($this);
234 234
         }
235 235
 
236 236
         return $this->numRevisions;
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     {
261 261
         $content = $this->getRepository()->getPagesWikitext(
262 262
             $this->getProject(),
263
-            [ $this->getTitle() ]
263
+            [$this->getTitle()]
264 264
         );
265 265
 
266 266
         return isset($content[$this->getTitle()])
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 
418 418
         $wikidataInfo = $this->getRepository()->getWikidataInfo($this);
419 419
 
420
-        $terms = array_map(function ($entry) {
420
+        $terms = array_map(function($entry) {
421 421
             return $entry['term'];
422 422
         }, $wikidataInfo);
423 423
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
                 'prio' => 2,
429 429
                 'name' => 'Wikidata',
430 430
                 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n
431
-                'explanation' => "See: <a target='_blank' " .
431
+                'explanation' => "See: <a target='_blank' ".
432 432
                     "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>",
433 433
             ];
434 434
         }
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                 'prio' => 3,
439 439
                 'name' => 'Wikidata',
440 440
                 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n
441
-                'explanation' => "See: <a target='_blank' " .
441
+                'explanation' => "See: <a target='_blank' ".
442 442
                     "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>",
443 443
             ];
444 444
         }
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
             return 0;
518 518
         }
519 519
 
520
-        return array_sum(array_map(function ($item) {
521
-            return (int) $item['views'];
520
+        return array_sum(array_map(function($item) {
521
+            return (int)$item['views'];
522 522
         }, $pageviews['items']));
523 523
     }
524 524
 
Please login to merge, or discard this patch.
src/AppBundle/EventSubscriber/RateLimitSubscriber.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
      */
57 57
     public function onKernelController(FilterControllerEvent $event)
58 58
     {
59
-        $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count');
60
-        $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time');
59
+        $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count');
60
+        $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time');
61 61
 
62 62
         // Zero values indicate the rate limiting feature should be disabled.
63 63
         if ($this->rateLimit === 0 || $this->rateDuration === 0) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         $controller = $event->getController();
68
-        $loggedIn = (bool) $this->container->get('session')->get('logged_in_user');
68
+        $loggedIn = (bool)$this->container->get('session')->get('logged_in_user');
69 69
 
70 70
         /**
71 71
          * Rate limiting will not apply to these actions
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         $cacheItem = $cache->getItem($cacheKey);
92 92
 
93 93
         // If increment value already in cache, or start with 1.
94
-        $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1;
94
+        $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1;
95 95
 
96 96
         // Check if limit has been exceeded, and if so, throw an error.
97 97
         if ($count > $this->rateLimit) {
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
         // Log the denied request
144 144
         $logger = $this->container->get('monolog.logger.rate_limit');
145 145
         $logger->info(
146
-            "<URI>: " . $request->getRequestUri() .
147
-            ($logComment != '' ? "\t<Reason>: $logComment" : '') .
148
-            "\t<User agent>: " . $request->headers->get('User-Agent')
146
+            "<URI>: ".$request->getRequestUri().
147
+            ($logComment != '' ? "\t<Reason>: $logComment" : '').
148
+            "\t<User agent>: ".$request->headers->get('User-Agent')
149 149
         );
150 150
 
151
-        throw new AccessDeniedHttpException("Possible spider crawl detected. " .
152
-            'If you are human, you are making too many requests during a short period of time. ' .
153
-            "Please wait $this->rateDuration minutes before reloading this tool. You can then " .
151
+        throw new AccessDeniedHttpException("Possible spider crawl detected. ".
152
+            'If you are human, you are making too many requests during a short period of time. '.
153
+            "Please wait $this->rateDuration minutes before reloading this tool. You can then ".
154 154
             'login to prevent this from happening again.');
155 155
     }
156 156
 }
Please login to merge, or discard this patch.
src/AppBundle/Controller/RfXAnalysisController.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,6 @@
 block discarded – undo
8 8
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9 9
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10 10
 use Symfony\Component\HttpFoundation\Request;
11
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
12 11
 use Xtools\ProjectRepository;
13 12
 use Xtools\Page;
14 13
 use Xtools\PagesRepository;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      * @Route("/rfx/{project}",        name="rfxAnalysisProject")
45 45
      * @Route("/rfx/{project}/{type}", name="rfxAnalysisProjectType")
46 46
      *
47
-     * @return Response|RedirectResponse
47
+     * @return \Symfony\Component\HttpFoundation\Response
48 48
      */
49 49
     public function indexAction(Request $request, $project = null, $type = null)
50 50
     {
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @Route("/rfx/{project}/{type}/{username}", name="rfxAnalysisResult")
112 112
      *
113
-     * @return Response|RedirectResponse
113
+     * @return \Symfony\Component\HttpFoundation\Response
114 114
      */
115 115
     public function resultAction($project, $type, $username)
116 116
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
166 166
         $neutral = $rfx->getSection('neutral');
167 167
         $dup = $rfx->getDuplicates();
168 168
 
169
-        $total = count($support) + count($oppose) + count($neutral);
169
+        $total = count($support)+count($oppose)+count($neutral);
170 170
 
171 171
         if ($total === 0) {
172 172
             $this->addFlash('notice', ['no-result', $pagename]);
Please login to merge, or discard this patch.
src/Xtools/RFX.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
      * Returns matches.
36 36
      *
37 37
      * @param string $input   The line we're looking for
38
-     * @param array  $matches Pointer to an array where we stash results
38
+     * @param string[]  $matches Pointer to an array where we stash results
39 39
      *
40 40
      * @TODO: Make this cleaner
41 41
      *
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             }
120 120
         }
121 121
 
122
-        $final = [];    // initialize the final array
122
+        $final = []; // initialize the final array
123 123
         $finalRaw = []; // Initialize the raw data array
124 124
 
125 125
         foreach ($this->data as $key => $value) {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
         $final = array_count_values($final); // find repetition and its count
134 134
 
135
-        $final = array_diff($final, [1]);    // remove single occurrences
135
+        $final = array_diff($final, [1]); // remove single occurrences
136 136
 
137 137
         $this->duplicates = array_keys($final);
138 138
     }
Please login to merge, or discard this patch.
src/Xtools/User.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@
 block discarded – undo
170 170
     /**
171 171
      * Get edit count within given timeframe and namespace
172 172
      * @param Project $project
173
-     * @param int|string $namespace Namespace ID or 'all' for all namespaces
173
+     * @param integer $namespace Namespace ID or 'all' for all namespaces
174 174
      * @param string $start Start date in a format accepted by strtotime()
175 175
      * @param string $end End date in a format accepted by strtotime()
176 176
      */
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             $this->getUsername()
90 90
         );
91 91
 
92
-        return (int) $editCount;
92
+        return (int)$editCount;
93 93
     }
94 94
 
95 95
     /**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function countAutomatedEdits(Project $project, $namespace = 'all', $start = '', $end = '')
206 206
     {
207
-        return (int) $this->getRepository()->countAutomatedEdits($project, $this, $namespace, $start, $end);
207
+        return (int)$this->getRepository()->countAutomatedEdits($project, $this, $namespace, $start, $end);
208 208
     }
209 209
 
210 210
     /**
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 
237 237
         $namespaces = $project->getNamespaces();
238 238
 
239
-        return array_map(function ($rev) use ($namespaces) {
239
+        return array_map(function($rev) use ($namespaces) {
240 240
             $pageTitle = $rev['page_title'];
241 241
             $fullPageTitle = '';
242 242
 
243 243
             if ($rev['page_namespace'] !== '0') {
244
-                $fullPageTitle = $namespaces[$rev['page_namespace']] . ":$pageTitle";
244
+                $fullPageTitle = $namespaces[$rev['page_namespace']].":$pageTitle";
245 245
             } else {
246 246
                 $fullPageTitle = $pageTitle;
247 247
             }
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
             return [
250 250
                 'full_page_title' => $fullPageTitle,
251 251
                 'page_title' => $pageTitle,
252
-                'page_namespace' => (int) $rev['page_namespace'],
253
-                'rev_id' => (int) $rev['rev_id'],
252
+                'page_namespace' => (int)$rev['page_namespace'],
253
+                'rev_id' => (int)$rev['rev_id'],
254 254
                 'timestamp' => DateTime::createFromFormat('YmdHis', $rev['timestamp']),
255
-                'minor' => (bool) $rev['minor'],
256
-                'length' => (int) $rev['length'],
257
-                'length_change' => (int) $rev['length_change'],
255
+                'minor' => (bool)$rev['minor'],
256
+                'length' => (int)$rev['length'],
257
+                'length_change' => (int)$rev['length_change'],
258 258
                 'comment' => $rev['comment'],
259 259
             ];
260 260
         }, $revs);
Please login to merge, or discard this patch.
src/AppBundle/Controller/EditCounterController.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,6 @@
 block discarded – undo
13 13
 use Symfony\Component\HttpFoundation\JsonResponse;
14 14
 use Xtools\EditCounter;
15 15
 use Xtools\EditCounterRepository;
16
-use Xtools\Page;
17 16
 use Xtools\Project;
18 17
 use Xtools\ProjectRepository;
19 18
 use Xtools\User;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
         $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
137 137
 
138 138
         return $this->render('editCounter/result.html.twig', [
139
-            'xtTitle' => $this->user->getUsername() . ' - ' . $this->project->getTitle(),
139
+            'xtTitle' => $this->user->getUsername().' - '.$this->project->getTitle(),
140 140
             'xtPage' => 'ec',
141 141
             'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
142 142
             'is_sub_request' => $isSubRequest,
Please login to merge, or discard this patch.