Completed
Pull Request — master (#96)
by MusikAnimal
02:39
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
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
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
                 });
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function countAllRevisions()
219 219
     {
220
-        return $this->countLiveRevisions() + $this->countDeletedRevisions();
220
+        return $this->countLiveRevisions()+$this->countDeletedRevisions();
221 221
     }
222 222
 
223 223
     /**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function countRevisionsWithoutComments()
238 238
     {
239
-        return $this->countLiveRevisions() - $this->countRevisionsWithComments();
239
+        return $this->countLiveRevisions()-$this->countRevisionsWithComments();
240 240
     }
241 241
 
242 242
     /**
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function countAllPagesEdited()
277 277
     {
278
-        return $this->countLivePagesEdited() + $this->countDeletedPagesEdited();
278
+        return $this->countLivePagesEdited()+$this->countDeletedPagesEdited();
279 279
     }
280 280
 
281 281
     /**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
      */
286 286
     public function countPagesCreated()
287 287
     {
288
-        return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted();
288
+        return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted();
289 289
     }
290 290
 
291 291
     /**
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
             // Try block just in case there are older, unpredictable formats
414 414
             try {
415 415
                 $expiry = strtotime($durationStr, $timestamp);
416
-                $duration = ($expiry - $timestamp) / (60 * 60 * 24);
416
+                $duration = ($expiry-$timestamp) / (60 * 60 * 24);
417 417
 
418 418
                 if (!$duration || $duration > $this->longestBlockDays) {
419 419
                     $this->longestBlockDays = $duration;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
         $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0;
498 498
         $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0;
499 499
         $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0;
500
-        return $import + $interwiki + $upload;
500
+        return $import+$interwiki+$upload;
501 501
     }
502 502
 
503 503
     /**
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
     public function approvals()
622 622
     {
623 623
         $logCounts = $this->getLogCounts();
624
-        $total = $logCounts['review-approve'] +
625
-        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) +
626
-        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) +
624
+        $total = $logCounts['review-approve']+
625
+        (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+
626
+        (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+
627 627
         (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0);
628 628
         return $total;
629 629
     }
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
         $logCounts = $this->getLogCounts();
648 648
         $create2 = $logCounts['newusers-create2'] ?: 0;
649 649
         $byemail = $logCounts['newusers-byemail'] ?: 0;
650
-        return $create2 + $byemail;
650
+        return $create2+$byemail;
651 651
     }
652 652
 
653 653
     /**
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 
700 700
         $totals = $this->getRepository()->getMonthCounts($this->project, $this->user);
701 701
         $out = [
702
-            'yearLabels' => [],  // labels for years
702
+            'yearLabels' => [], // labels for years
703 703
             'monthLabels' => [], // labels for months
704 704
             'totals' => [], // actual totals, grouped by namespace, year and then month
705 705
         ];
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
                 $out['totals'][$ns][$total['year']] = [];
728 728
             }
729 729
 
730
-            $out['totals'][$ns][$total['year']][$total['month']] = (int) $total['count'];
730
+            $out['totals'][$ns][$total['year']][$total['month']] = (int)$total['count'];
731 731
         }
732 732
 
733 733
         $dateRange = new DatePeriod(
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
         );
738 738
 
739 739
         foreach ($dateRange as $monthObj) {
740
-            $year = (int) $monthObj->format('Y');
741
-            $month = (int) $monthObj->format('n');
740
+            $year = (int)$monthObj->format('Y');
741
+            $month = (int)$monthObj->format('n');
742 742
 
743 743
             // Fill in labels
744 744
             $out['monthLabels'][] = $monthObj->format('Y-m');
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
                 ->globalEditCounts($this->user, $this->project);
853 853
             if ($sorted) {
854 854
                 // Sort.
855
-                uasort($this->globalEditCounts, function ($a, $b) {
856
-                    return $b['total'] - $a['total'];
855
+                uasort($this->globalEditCounts, function($a, $b) {
856
+                    return $b['total']-$a['total'];
857 857
                 });
858 858
             }
859 859
         }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 $nsName = $project->getNamespaces()[$revision['page_namespace']];
890 890
             }
891 891
             $page = $project->getRepository()
892
-                ->getPage($project, $nsName . ':' . $revision['page_title']);
892
+                ->getPage($project, $nsName.':'.$revision['page_title']);
893 893
             $edit = new Edit($page, $revision);
894 894
             $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit;
895 895
         }
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
     public function countSmallEdits()
931 931
     {
932 932
         $editSizeData = $this->getEditSizeData();
933
-        return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0;
933
+        return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0;
934 934
     }
935 935
 
936 936
     /**
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
     public function countLargeEdits()
941 941
     {
942 942
         $editSizeData = $this->getEditSizeData();
943
-        return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0;
943
+        return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0;
944 944
     }
945 945
 
946 946
     /**
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.