Completed
Pull Request — master (#72)
by MusikAnimal
02:35
created
src/Xtools/PagesRepository.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
      * Get metadata about a single page from the API.
19 19
      * @param Project $project The project to which the page belongs.
20 20
      * @param string $pageTitle Page title.
21
-     * @return string[] Array with some of the following keys: pageid, title, missing, displaytitle,
21
+     * @return string|null Array with some of the following keys: pageid, title, missing, displaytitle,
22 22
      * url.
23 23
      */
24 24
     public function getPageInfo(Project $project, $pageTitle)
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * Get the statement for a single revision, so that you can iterate row by row.
97 97
      * @param Page $page The page.
98 98
      * @param User|null $user Specify to get only revisions by the given user.
99
-     * @return Doctrine\DBAL\Driver\PDOStatement
99
+     * @return \Doctrine\DBAL\Driver\Statement
100 100
      */
101 101
     public function getRevisionsStmt(Page $page, User $user = null)
102 102
     {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
         $wikidataId = ltrim($page->getWikidataId(), 'Q');
324 324
 
325
-        $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . "
325
+        $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')."
326 326
                 FROM wikidatawiki_p.wb_items_per_site
327 327
                 WHERE ips_item_id = :wikidataId";
328 328
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
         $result = $resultQuery->fetchAll();
334 334
 
335
-        return $count ? (int) $result[0]['count'] : $result;
335
+        return $count ? (int)$result[0]['count'] : $result;
336 336
     }
337 337
 
338 338
     /**
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 
373 373
         // Transform to associative array by 'type'
374 374
         foreach ($res as $row) {
375
-            $data[$row['type'] . '_count'] = $row['value'];
375
+            $data[$row['type'].'_count'] = $row['value'];
376 376
         }
377 377
 
378 378
         return $data;
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 
410 410
         $project = $page->getProject()->getDomain();
411 411
 
412
-        $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' .
412
+        $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'.
413 413
             "$project/all-access/user/$title/daily/$start/$end";
414 414
 
415 415
         $res = $client->request('GET', $url);
Please login to merge, or discard this patch.
src/AppBundle/Controller/ApiController.php 2 patches
Unused Use Statements   -4 removed lines patch added patch discarded remove patch
@@ -5,12 +5,8 @@
 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
-use Symfony\Component\HttpFoundation\Request;
12 9
 use Symfony\Component\HttpFoundation\Response;
13
-use Symfony\Component\Debug\Exception\FatalErrorException;
14 10
 use FOS\RestBundle\Controller\Annotations as Rest;
15 11
 use FOS\RestBundle\Controller\FOSRestController;
16 12
 use FOS\RestBundle\View\View;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
         $data = $user->getNonautomatedEdits($project, $namespace, $start, $end, $offset);
107 107
 
108 108
         if ($format === 'html') {
109
-            $edits = array_map(function ($attrs) use ($project, $username) {
109
+            $edits = array_map(function($attrs) use ($project, $username) {
110 110
                 $nsName = '';
111 111
                 if ($attrs['page_namespace']) {
112 112
                     $nsName = $project->getNamespaces()[$attrs['page_namespace']];
113 113
                 }
114 114
                 $page = $project->getRepository()
115
-                    ->getPage($project, $nsName . ':' . $attrs['page_title']);
115
+                    ->getPage($project, $nsName.':'.$attrs['page_title']);
116 116
                 $attrs['id'] = $attrs['rev_id'];
117 117
                 $attrs['username'] = $username;
118 118
                 return new Edit($page, $attrs);
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
             ->format('Y-m-d H:i');
166 166
 
167 167
         $data = [
168
-            'revisions' => (int) $info['num_edits'],
169
-            'editors' => (int) $info['num_editors'],
168
+            'revisions' => (int)$info['num_edits'],
169
+            'editors' => (int)$info['num_editors'],
170 170
             'author' => $info['author'],
171
-            'author_editcount' => (int) $info['author_editcount'],
171
+            'author_editcount' => (int)$info['author_editcount'],
172 172
             'created_at' => $creationDateTime,
173 173
             'modified_at' => $modifiedDateTime,
174
-            'watchers' => (int) $page->getWatchers(),
174
+            'watchers' => (int)$page->getWatchers(),
175 175
             'pageviews' => $page->getLastPageviews($pageviewsOffset),
176 176
             'pageviews_offset' => $pageviewsOffset,
177 177
         ];
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         }
223 223
 
224 224
         $conn = $this->getDoctrine()->getManager('default')->getConnection();
225
-        $date =  date('Y-m-d');
225
+        $date = date('Y-m-d');
226 226
 
227 227
         // Increment count in timeline
228 228
         $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 page views 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   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
         // Otherwise do a COUNT in the event fetching
185 185
         // all revisions is not desired
186
-        return (int) $this->getRepository()->getNumRevisions($this, $user);
186
+        return (int)$this->getRepository()->getNumRevisions($this, $user);
187 187
     }
188 188
 
189 189
     /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
         $wikidataInfo = $this->getRepository()->getWikidataInfo($this);
343 343
 
344
-        $terms = array_map(function ($entry) {
344
+        $terms = array_map(function($entry) {
345 345
             return $entry['term'];
346 346
         }, $wikidataInfo);
347 347
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                 'prio' => 2,
353 353
                 'name' => 'Wikidata',
354 354
                 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n
355
-                'explanation' => "See: <a target='_blank' " .
355
+                'explanation' => "See: <a target='_blank' ".
356 356
                     "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>",
357 357
             ];
358 358
         }
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
                 'prio' => 3,
363 363
                 'name' => 'Wikidata',
364 364
                 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n
365
-                'explanation' => "See: <a target='_blank' " .
365
+                'explanation' => "See: <a target='_blank' ".
366 366
                     "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>",
367 367
             ];
368 368
         }
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
 
440 440
         $pageviews = $this->getPageviews($start, $end);
441 441
 
442
-        return array_sum(array_map(function ($item) {
443
-            return (int) $item['views'];
442
+        return array_sum(array_map(function($item) {
443
+            return (int)$item['views'];
444 444
         }, $pageviews['items']));
445 445
     }
446 446
 }
Please login to merge, or discard this patch.