Completed
Pull Request — master (#96)
by MusikAnimal
03:52 queued 01:31
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   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 
118 118
         foreach ($endpoints as $key => $endpoint) {
119 119
             // $promise = $this->getRepository()->queryXTools($endpoint, true);
120
-            $promise = $client->getAsync('https://xtools-dev.wmflabs.org/' . $endpoint);
120
+            $promise = $client->getAsync('https://xtools-dev.wmflabs.org/'.$endpoint);
121 121
             $promises[] = $promise;
122 122
 
123 123
             // Handle response of $promise asynchronously.
124
-            $promise->then(function ($response) use ($key, $endpoint) {
125
-                $result = (array) json_decode($response->getBody()->getContents());
124
+            $promise->then(function($response) use ($key, $endpoint) {
125
+                $result = (array)json_decode($response->getBody()->getContents());
126 126
 
127 127
                 if (isset($result)) {
128 128
                     // Copy result to the class class instance. From here any subsequent
@@ -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
                         ->log
138
-                        ->err("Failed to fetch data for $endpoint via async, " .
138
+                        ->err("Failed to fetch data for $endpoint via async, ".
139 139
                             "re-attempting synchoronously.");
140 140
                 }
141 141
             });
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public function countAllRevisions()
218 218
     {
219
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
219
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
220 220
     }
221 221
 
222 222
     /**
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function countRevisionsWithoutComments()
237 237
     {
238
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
238
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
239 239
     }
240 240
 
241 241
     /**
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public function countAllPagesEdited()
276 276
     {
277
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
277
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
278 278
     }
279 279
 
280 280
     /**
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     public function countPagesCreated()
286 286
     {
287
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
287
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
288 288
     }
289 289
 
290 290
     /**
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             // Try block just in case there are older, unpredictable formats
413 413
             try {
414 414
                 $expiry = strtotime($durationStr, $timestamp);
415
-                $duration = ($expiry - $timestamp) / (60 * 60 * 24);
415
+                $duration = ($expiry-$timestamp) / (60 * 60 * 24);
416 416
 
417 417
                 if (!$duration || $duration > $this->longestBlockDays) {
418 418
                     $this->longestBlockDays = $duration;
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
497 497
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
498 498
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
499
-        return $import + $interwiki + $upload;
499
+        return $import+$interwiki+$upload;
500 500
     }
501 501
 
502 502
     /**
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
     public function approvals()
621 621
     {
622 622
         $logCounts = $this->getLogCounts();
623
-        $total = $logCounts['review-approve'] +
624
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
625
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
623
+        $total = $logCounts['review-approve']+
624
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
625
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
626 626
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
627 627
         return $total;
628 628
     }
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
         $logCounts = $this->getLogCounts();
647 647
         $create2 = $logCounts['newusers-create2'] ?: 0;
648 648
         $byemail = $logCounts['newusers-byemail'] ?: 0;
649
-        return $create2 + $byemail;
649
+        return $create2+$byemail;
650 650
     }
651 651
 
652 652
     /**
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
700 700
         $out = [
701
-            'yearLabels' => [],  // labels for years
701
+            'yearLabels' => [], // labels for years
702 702
             'monthLabels' => [], // labels for months
703 703
             'totals' => [], // actual totals, grouped by namespace, year and then month
704 704
         ];
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
                 $out['totals'][$ns][$total['year']] = [];
727 727
             }
728 728
 
729
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
729
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
730 730
         }
731 731
 
732 732
         $dateRange = new DatePeriod(
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
         );
737 737
 
738 738
         foreach ($dateRange as $monthObj) {
739
-            $year = (int) $monthObj->format('Y');
740
-            $month = (int) $monthObj->format('n');
739
+            $year = (int)$monthObj->format('Y');
740
+            $month = (int)$monthObj->format('n');
741 741
 
742 742
             // Fill in labels
743 743
             $out['monthLabels'][] = $monthObj->format('Y-m');
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 
854 854
         if ($sorted) {
855 855
             // Sort.
856
-            uasort($this->globalEditCounts, function ($a, $b) {
857
-                return $b['total'] - $a['total'];
856
+            uasort($this->globalEditCounts, function($a, $b) {
857
+                return $b['total']-$a['total'];
858 858
             });
859 859
         }
860 860
 
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
891 891
             }
892 892
             $page = $project->getRepository()
893
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
893
+                ->getPage($project, $nsName.':'.$revision['page_title']);
894 894
             $edit = new Edit($page, $revision);
895 895
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
896 896
         }
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
     public function countSmallEdits()
932 932
     {
933 933
         $editSizeData = $this->getEditSizeData();
934
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
934
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
935 935
     }
936 936
 
937 937
     /**
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
     public function countLargeEdits()
942 942
     {
943 943
         $editSizeData = $this->getEditSizeData();
944
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
944
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
945 945
     }
946 946
 
947 947
     /**
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 . '/' . $endpoint;
154
+        $endpoint = $apiRoot.'/'.$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.