Completed
Pull Request — master (#96)
by MusikAnimal
02:13
created
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   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
         $username = $request->query->get('username', $request->query->get('user'));
99 99
 
100 100
         if (($project || $queryProject) && $username) {
101
-            $routeParams = [ 'project'=>($project ?: $queryProject), 'username' => $username ];
101
+            $routeParams = ['project'=>($project ?: $queryProject), 'username' => $username];
102 102
             return $this->redirectToRoute("EditCounterResult", $routeParams);
103 103
         } elseif (!$project && $queryProject) {
104
-            return $this->redirectToRoute("EditCounterProject", [ 'project'=>$queryProject ]);
104
+            return $this->redirectToRoute("EditCounterProject", ['project'=>$queryProject]);
105 105
         }
106 106
 
107 107
         $project = ProjectRepository::getProject($queryProject, $this->container);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
142 142
 
143 143
         return $this->render('editCounter/result.html.twig', [
144
-            'xtTitle' => $this->user->getUsername() . ' - ' . $this->project->getTitle(),
144
+            'xtTitle' => $this->user->getUsername().' - '.$this->project->getTitle(),
145 145
             'xtPage' => 'ec',
146 146
             'base_dir' => realpath($this->getParameter('kernel.root_dir').'/..'),
147 147
             'is_sub_request' => $isSubRequest,
Please login to merge, or discard this patch.
src/Xtools/EditCounter.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * This method asynchronously fetches all the expensive data, waits
86 86
      * for each request to finish, and copies the values to the class instance.
87
-     * @param ContainerInterface $container Symfony's container.
87
+     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Symfony's container.
88 88
      * @return null
89 89
      */
90 90
     public function prepareData($container)
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 
545 545
     /**
546 546
      * Get the date and time of the user's first edit.
547
-     * @return DateTime|bool The time of the first revision, or false.
547
+     * @return DateInterval The time of the first revision, or false.
548 548
      */
549 549
     public function datetimeFirstRevision()
550 550
     {
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 
555 555
     /**
556 556
      * Get the date and time of the user's first edit.
557
-     * @return DateTime|bool The time of the last revision, or false.
557
+     * @return DateInterval The time of the last revision, or false.
558 558
      */
559 559
     public function datetimeLastRevision()
560 560
     {
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
             $promises[] = $promise;
119 119
 
120 120
             // Handle response of $promise asynchronously.
121
-            $promise->then(function ($response) use ($key, $endpoint) {
122
-                $result = (array) json_decode($response->getBody()->getContents());
121
+            $promise->then(function($response) use ($key, $endpoint) {
122
+                $result = (array)json_decode($response->getBody()->getContents());
123 123
 
124 124
                 if (isset($result)) {
125 125
                     // Copy result to the class class instance. From here any subsequent
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
                     // We'll log this to see how often it happens.
133 133
                     $this->getRepository()
134 134
                         ->log
135
-                        ->err("Failed to fetch data for $endpoint via async, " .
135
+                        ->err("Failed to fetch data for $endpoint via async, ".
136 136
                             "re-attempting synchoronously.");
137 137
                 }
138 138
             });
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function countAllRevisions()
215 215
     {
216
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
216
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
217 217
     }
218 218
 
219 219
     /**
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function countRevisionsWithoutComments()
234 234
     {
235
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
235
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
236 236
     }
237 237
 
238 238
     /**
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      */
272 272
     public function countAllPagesEdited()
273 273
     {
274
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
274
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
275 275
     }
276 276
 
277 277
     /**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function countPagesCreated()
283 283
     {
284
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
284
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
285 285
     }
286 286
 
287 287
     /**
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
             // Try block just in case there are older, unpredictable formats
410 410
             try {
411 411
                 $expiry = strtotime($durationStr, $timestamp);
412
-                $duration = ($expiry - $timestamp) / (60 * 60 * 24);
412
+                $duration = ($expiry-$timestamp) / (60 * 60 * 24);
413 413
 
414 414
                 if (!$duration || $duration > $this->longestBlockDays) {
415 415
                     $this->longestBlockDays = $duration;
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
494 494
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
495 495
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
496
-        return $import + $interwiki + $upload;
496
+        return $import+$interwiki+$upload;
497 497
     }
498 498
 
499 499
     /**
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
     public function approvals()
618 618
     {
619 619
         $logCounts = $this->getLogCounts();
620
-        $total = $logCounts['review-approve'] +
621
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
622
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
620
+        $total = $logCounts['review-approve']+
621
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
622
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
623 623
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
624 624
         return $total;
625 625
     }
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
         $logCounts = $this->getLogCounts();
644 644
         $create2 = $logCounts['newusers-create2'] ?: 0;
645 645
         $byemail = $logCounts['newusers-byemail'] ?: 0;
646
-        return $create2 + $byemail;
646
+        return $create2+$byemail;
647 647
     }
648 648
 
649 649
     /**
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 
696 696
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
697 697
         $out = [
698
-            'yearLabels' => [],  // labels for years
698
+            'yearLabels' => [], // labels for years
699 699
             'monthLabels' => [], // labels for months
700 700
             'totals' => [], // actual totals, grouped by namespace, year and then month
701 701
         ];
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
                 $out['totals'][$ns][$total['year']] = [];
724 724
             }
725 725
 
726
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
726
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
727 727
         }
728 728
 
729 729
         $dateRange = new DatePeriod(
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
         );
734 734
 
735 735
         foreach ($dateRange as $monthObj) {
736
-            $year = (int) $monthObj->format('Y');
737
-            $month = (int) $monthObj->format('n');
736
+            $year = (int)$monthObj->format('Y');
737
+            $month = (int)$monthObj->format('n');
738 738
 
739 739
             // Fill in labels
740 740
             $out['monthLabels'][] = $monthObj->format('Y-m');
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 
851 851
         if ($sorted) {
852 852
             // Sort.
853
-            uasort($this->globalEditCounts, function ($a, $b) {
854
-                return $b['total'] - $a['total'];
853
+            uasort($this->globalEditCounts, function($a, $b) {
854
+                return $b['total']-$a['total'];
855 855
             });
856 856
         }
857 857
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
888 888
             }
889 889
             $page = $project->getRepository()
890
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
890
+                ->getPage($project, $nsName.':'.$revision['page_title']);
891 891
             $edit = new Edit($page, $revision);
892 892
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
893 893
         }
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
     public function countSmallEdits()
929 929
     {
930 930
         $editSizeData = $this->getEditSizeData();
931
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
931
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
932 932
     }
933 933
 
934 934
     /**
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
     public function countLargeEdits()
939 939
     {
940 940
         $editSizeData = $this->getEditSizeData();
941
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
941
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
942 942
     }
943 943
 
944 944
     /**
Please login to merge, or discard this patch.
src/Xtools/Repository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
         // Ensure there's a trailing slash.
153 153
         $apiRoot = trim($this->container->getParameter('app.multithread.api_url'), '/');
154
-        $endpoint = $apiRoot . '/api/' . $endpoint;
154
+        $endpoint = $apiRoot.'/api/'.$endpoint;
155 155
 
156 156
         if ($async) {
157 157
             return $this->apiConnection->getAsync($endpoint);
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         // $tableExtension in order to generate the new table name
178 178
         if ($this->isLabs() && $tableExtension !== null) {
179 179
             $mapped = true;
180
-            $tableName = $tableName . '_' . $tableExtension;
180
+            $tableName = $tableName.'_'.$tableExtension;
181 181
         } elseif ($this->container->hasParameter("app.table.$tableName")) {
182 182
             // Use the table specified in the table mapping configuration, if present.
183 183
             $mapped = true;
Please login to merge, or discard this patch.