Completed
Pull Request — master (#107)
by Matthew
06:24
created
src/AppBundle/Controller/MetaController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $end = $request->query->get('end');
32 32
 
33 33
         if ($start != '' && $end != '') {
34
-            return $this->redirectToRoute('MetaResult', [ 'start' => $start, 'end' => $end ]);
34
+            return $this->redirectToRoute('MetaResult', ['start' => $start, 'end' => $end]);
35 35
         }
36 36
 
37 37
         return $this->render('meta/index.html.twig', [
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $timeline = [];
74 74
         $startObj = new DateTime($start);
75 75
         $endObj = new DateTime($end);
76
-        $numDays = (int) $endObj->diff($startObj)->format("%a");
76
+        $numDays = (int)$endObj->diff($startObj)->format("%a");
77 77
         $grandSum = 0;
78 78
 
79 79
         // Generate array of date labels
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 
84 84
         foreach ($data as $entry) {
85 85
             if (!isset($totals[$entry['tool']])) {
86
-                $totals[$entry['tool']] = (int) $entry['count'];
86
+                $totals[$entry['tool']] = (int)$entry['count'];
87 87
 
88 88
                 // Create arrays for each tool, filled with zeros for each date in the timeline
89 89
                 $timeline[$entry['tool']] = array_fill(0, $numDays, 0);
90 90
             } else {
91
-                $totals[$entry['tool']] += (int) $entry['count'];
91
+                $totals[$entry['tool']] += (int)$entry['count'];
92 92
             }
93 93
 
94 94
             $date = new DateTime($entry['date']);
95
-            $dateIndex = (int) $date->diff($startObj)->format("%a");
96
-            $timeline[$entry['tool']][$dateIndex] = (int) $entry['count'];
95
+            $dateIndex = (int)$date->diff($startObj)->format("%a");
96
+            $timeline[$entry['tool']][$dateIndex] = (int)$entry['count'];
97 97
 
98 98
             $grandSum += $entry['count'];
99 99
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         }
144 144
 
145 145
         $conn = $this->container->get('doctrine')->getManager('default')->getConnection();
146
-        $date =  date('Y-m-d');
146
+        $date = date('Y-m-d');
147 147
 
148 148
         // Increment count in timeline
149 149
         $existsSql = "SELECT 1 FROM usage_timeline
Please login to merge, or discard this patch.
src/Xtools/EditCounter.php 1 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
                 $this->getRepository()
124 124
                     ->getLog()
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                     // We'll log this to see how often it happens.
136 136
                     $this->getRepository()
137 137
                         ->getLog()
138
-                        ->error("Failed to fetch data for $endpoint via async, " .
138
+                        ->error("Failed to fetch data for $endpoint via async, ".
139 139
                             "re-attempting synchoronously.");
140 140
                 }
141 141
             });
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
         // Filter out unblocks unless requested.
193 193
         if ($blocksOnly) {
194
-            $blocks = array_filter($blocks, function ($block) {
194
+            $blocks = array_filter($blocks, function($block) {
195 195
                 return $block['log_action'] === 'block';
196 196
             });
197 197
         }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function countAllRevisions()
227 227
     {
228
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
228
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
229 229
     }
230 230
 
231 231
     /**
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      */
245 245
     public function countRevisionsWithoutComments()
246 246
     {
247
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
247
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
248 248
     }
249 249
 
250 250
     /**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function countAllPagesEdited()
285 285
     {
286
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
286
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
287 287
     }
288 288
 
289 289
     /**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function countPagesCreated()
295 295
     {
296
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
296
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
297 297
     }
298 298
 
299 299
     /**
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
             } elseif ($block['log_action'] === 'unblock') {
434 434
                 // The last block was lifted. So the duration will be the time from when the
435 435
                 // last block was set to the time of the unblock.
436
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
436
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
437 437
                 if ($timeSinceLastBlock > $this->longestBlockSeconds) {
438 438
                     $this->longestBlockSeconds = $timeSinceLastBlock;
439 439
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
                 // The last block was modified. So we will adjust $lastBlock to include
445 445
                 // the difference of the duration of the new reblock, and time since the last block.
446 446
                 // $lastBlock is left unchanged if its duration was indefinite.
447
-                $timeSinceLastBlock = $timestamp - $lastBlock[0];
448
-                $lastBlock[1] = $timeSinceLastBlock + $duration;
447
+                $timeSinceLastBlock = $timestamp-$lastBlock[0];
448
+                $lastBlock[1] = $timeSinceLastBlock+$duration;
449 449
             }
450 450
         }
451 451
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
         }
456 456
 
457 457
         // Test if the last block is still active, and if so use the expiry as the duration.
458
-        $lastBlockExpiry = $lastBlock[0] + $lastBlock[1];
458
+        $lastBlockExpiry = $lastBlock[0]+$lastBlock[1];
459 459
         if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) {
460 460
             $this->longestBlockSeconds = $lastBlock[1];
461 461
         // Otherwise, test if the duration of the last block is now the longest overall.
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
         // If invalid, $duration is left as null.
497 497
         if (strtotime($durationStr)) {
498 498
             $expiry = strtotime($durationStr, $timestamp);
499
-            $duration = $expiry - $timestamp;
499
+            $duration = $expiry-$timestamp;
500 500
         }
501 501
 
502 502
         return [$timestamp, $duration];
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
574 574
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
575 575
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
576
-        return $import + $interwiki + $upload;
576
+        return $import+$interwiki+$upload;
577 577
     }
578 578
 
579 579
     /**
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
     public function approvals()
698 698
     {
699 699
         $logCounts = $this->getLogCounts();
700
-        $total = $logCounts['review-approve'] +
701
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
702
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
700
+        $total = $logCounts['review-approve']+
701
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
702
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
703 703
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
704 704
         return $total;
705 705
     }
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
         $logCounts = $this->getLogCounts();
724 724
         $create2 = $logCounts['newusers-create2'] ?: 0;
725 725
         $byemail = $logCounts['newusers-byemail'] ?: 0;
726
-        return $create2 + $byemail;
726
+        return $create2+$byemail;
727 727
     }
728 728
 
729 729
     /**
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
777 777
         $out = [
778
-            'yearLabels' => [],  // labels for years
778
+            'yearLabels' => [], // labels for years
779 779
             'monthLabels' => [], // labels for months
780 780
             'totals' => [], // actual totals, grouped by namespace, year and then month
781 781
         ];
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
                 $out['totals'][$ns][$total['year']] = [];
804 804
             }
805 805
 
806
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
806
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
807 807
         }
808 808
 
809 809
         $dateRange = new DatePeriod(
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
         );
814 814
 
815 815
         foreach ($dateRange as $monthObj) {
816
-            $year = (int) $monthObj->format('Y');
817
-            $month = (int) $monthObj->format('n');
816
+            $year = (int)$monthObj->format('Y');
817
+            $month = (int)$monthObj->format('n');
818 818
 
819 819
             // Fill in labels
820 820
             $out['monthLabels'][] = $monthObj->format('Y-m');
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 
931 931
         if ($sorted) {
932 932
             // Sort.
933
-            uasort($this->globalEditCounts, function ($a, $b) {
934
-                return $b['total'] - $a['total'];
933
+            uasort($this->globalEditCounts, function($a, $b) {
934
+                return $b['total']-$a['total'];
935 935
             });
936 936
         }
937 937
 
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
968 968
             }
969 969
             $page = $project->getRepository()
970
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
970
+                ->getPage($project, $nsName.':'.$revision['page_title']);
971 971
             $edit = new Edit($page, $revision);
972 972
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
973 973
         }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
     public function countSmallEdits()
1009 1009
     {
1010 1010
         $editSizeData = $this->getEditSizeData();
1011
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
1011
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
1012 1012
     }
1013 1013
 
1014 1014
     /**
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
     public function countLargeEdits()
1019 1019
     {
1020 1020
         $editSizeData = $this->getEditSizeData();
1021
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
1021
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
1022 1022
     }
1023 1023
 
1024 1024
     /**
Please login to merge, or discard this patch.
src/Xtools/TopEdits.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
         $pages = [];
125 125
         foreach ($topPages as $page) {
126 126
             // If non-mainspace, prepend namespace to the titles.
127
-            $ns = (int) $page['page_namespace'];
128
-            $nsTitle = $ns > 0 ? $this->project->getNamespaces()[$page['page_namespace']] . ':' : '';
129
-            $pageTitle = $nsTitle . $page['page_title'];
127
+            $ns = (int)$page['page_namespace'];
128
+            $nsTitle = $ns > 0 ? $this->project->getNamespaces()[$page['page_namespace']].':' : '';
129
+            $pageTitle = $nsTitle.$page['page_title'];
130 130
             $page['displaytitle'] = $displayTitles[$pageTitle];
131 131
             // $page['page_title'] is retained without the namespace
132 132
             //  so we can link to TopEdits for that page.
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
         $namespaces = $this->project->getNamespaces();
148 148
 
149 149
         // First extract page titles including namespace.
150
-        $pageTitles = array_map(function ($page) use ($namespaces) {
150
+        $pageTitles = array_map(function($page) use ($namespaces) {
151 151
             // If non-mainspace, prepend namespace to the titles.
152 152
             $ns = $page['page_namespace'];
153
-            $nsTitle = $ns > 0 ? $namespaces[$page['page_namespace']] . ':' : '';
154
-            return $nsTitle . $page['page_title'];
153
+            $nsTitle = $ns > 0 ? $namespaces[$page['page_namespace']].':' : '';
154
+            return $nsTitle.$page['page_title'];
155 155
         }, $topPages);
156 156
 
157 157
         return $this->getRepository()->getDisplayTitles($this->project, $pageTitles);
Please login to merge, or discard this patch.
src/AppBundle/Controller/TopEditsController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             'xtSubtitle' => 'tool-topedits-desc',
97 97
             'xtPage' => 'topedits',
98 98
             'project' => $project,
99
-            'namespace' => (int) $namespace,
99
+            'namespace' => (int)$namespace,
100 100
             'article' => $article,
101 101
         ]);
102 102
     }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         // Send all to the template.
249 249
         return $this->render('topedits/result_article.html.twig', [
250 250
             'xtPage' => 'topedits',
251
-            'xtTitle' => $user->getUsername() . ' - ' . $page->getTitle(),
251
+            'xtTitle' => $user->getUsername().' - '.$page->getTitle(),
252 252
             'project' => $project,
253 253
             'user' => $user,
254 254
             'page' => $page,
Please login to merge, or discard this patch.
src/Xtools/TopEditsRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
         $hasPageAssessments = $this->isLabs() && $project->hasPageAssessments() && $namespace === 0;
40 40
         $pageAssessmentsTable = $this->getTableName($project->getDatabaseName(), 'page_assessments');
41 41
         $paSelect = $hasPageAssessments
42
-            ?  ", (
42
+            ? ", (
43 43
                     SELECT pa_class
44 44
                     FROM page_assessments
45 45
                     WHERE pa_page_id = page_id
Please login to merge, or discard this patch.
src/AppBundle/Controller/DeleteCounterController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
         // If we've got a project and user, redirect to results.
58 58
         if ($projectName != '' && $username != '') {
59
-            $routeParams = [ 'project' => $projectName, 'username' => $username ];
59
+            $routeParams = ['project' => $projectName, 'username' => $username];
60 60
             return $this->redirectToRoute(
61 61
                 'DeletionCounterResult',
62 62
                 $routeParams
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         $types = $this->container->getParameter("deletion_counter");
128 128
 
129 129
         if (!isset($types[$project->getDatabaseName()])) {
130
-            $this->addFlash('notice', [ 'no-result', $username ]);
130
+            $this->addFlash('notice', ['no-result', $username]);
131 131
             return $this->redirectToRoute(
132 132
                 'DeletionCounter',
133 133
                 [
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         $resultQuery->execute();
154 154
 
155 155
         if ($resultQuery->errorCode() > 0) {
156
-            $this->addFlash('notice', [ 'no-result', $username ]);
156
+            $this->addFlash('notice', ['no-result', $username]);
157 157
             return $this->redirectToRoute(
158 158
                 'DeletionCounterProject',
159 159
                 [
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         // Unknown user or generated no results
173 173
         // This is a workaround to detect non-existent IPs.
174 174
         if (count($results) == 0) {
175
-            $this->addFlash('notice', [ 'no-result', $username ]);
175
+            $this->addFlash('notice', ['no-result', $username]);
176 176
 
177 177
             return $this->redirectToRoute(
178 178
                 'DeletionCounterProject',
Please login to merge, or discard this patch.