Completed
Push — master ( 77d109...dc7aae )
by Sam
05:53 queued 03:04
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   +8 added lines, -8 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);
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
         $info = $page->getBasicEditingInfo();
160 160
         $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']);
161 161
         $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']);
162
-        $secsSinceLastEdit = $modifiedDateTime->getTimestamp() - $creationDateTime->getTimestamp();
162
+        $secsSinceLastEdit = $modifiedDateTime->getTimestamp()-$creationDateTime->getTimestamp();
163 163
 
164 164
         $data = [
165
-            'revisions' => (int) $info['num_edits'],
166
-            'editors' => (int) $info['num_editors'],
165
+            'revisions' => (int)$info['num_edits'],
166
+            'editors' => (int)$info['num_editors'],
167 167
             'author' => $info['author'],
168
-            'author_editcount' => (int) $info['author_editcount'],
168
+            'author_editcount' => (int)$info['author_editcount'],
169 169
             'created_at' => $creationDateTime->format('Y-m-d H:i'),
170 170
             'modified_at' => $modifiedDateTime->format('Y-m-d H:i'),
171 171
             'secs_since_last_edit' => $secsSinceLastEdit,
172
-            'watchers' => (int) $page->getWatchers(),
172
+            'watchers' => (int)$page->getWatchers(),
173 173
             'pageviews' => $page->getLastPageviews($pageviewsOffset),
174 174
             'pageviews_offset' => $pageviewsOffset,
175 175
         ];
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
         }
221 221
 
222 222
         $conn = $this->getDoctrine()->getManager('default')->getConnection();
223
-        $date =  date('Y-m-d');
223
+        $date = date('Y-m-d');
224 224
 
225 225
         // Increment count in timeline
226 226
         $existsSql = "SELECT 1 FROM usage_timeline
Please login to merge, or discard this patch.
src/Xtools/Page.php 2 patches
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.
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.
src/AppBundle/Twig/AppExtension.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,32 +32,32 @@  discard block
 block discarded – undo
32 32
     {
33 33
         $options = ['is_safe' => ['html']];
34 34
         return [
35
-            new \Twig_SimpleFunction('request_time', [ $this, 'requestTime' ], $options),
36
-            new \Twig_SimpleFunction('memory_usage', [ $this, 'requestMemory' ], $options),
37
-            new \Twig_SimpleFunction('year', [ $this, 'generateYear' ], $options),
38
-            new \Twig_SimpleFunction('msgPrintExists', [ $this, 'intuitionMessagePrintExists' ], $options),
39
-            new \Twig_SimpleFunction('msgExists', [ $this, 'intuitionMessageExists' ], $options),
40
-            new \Twig_SimpleFunction('msg', [ $this, 'intuitionMessage' ], $options),
41
-            new \Twig_SimpleFunction('lang', [ $this, 'getLang' ], $options),
42
-            new \Twig_SimpleFunction('langName', [ $this, 'getLangName' ], $options),
43
-            new \Twig_SimpleFunction('allLangs', [ $this, 'getAllLangs' ]),
44
-            new \Twig_SimpleFunction('isRTL', [ $this, 'intuitionIsRTL' ]),
45
-            new \Twig_SimpleFunction('isRTLLang', [ $this, 'intuitionIsRTLLang' ]),
46
-            new \Twig_SimpleFunction('shortHash', [ $this, 'gitShortHash' ]),
47
-            new \Twig_SimpleFunction('hash', [ $this, 'gitHash' ]),
48
-            new \Twig_SimpleFunction('enabled', [ $this, 'tabEnabled' ]),
49
-            new \Twig_SimpleFunction('tools', [ $this, 'allTools' ]),
50
-            new \Twig_SimpleFunction('color', [ $this, 'getColorList' ]),
51
-            new \Twig_SimpleFunction('chartColor', [ $this, 'chartColor' ]),
52
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
53
-            new \Twig_SimpleFunction('isSingleWiki', [ $this, 'isSingleWiki' ]),
54
-            new \Twig_SimpleFunction('getReplagThreshold', [ $this, 'getReplagThreshold' ]),
55
-            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [ $this, 'loadStylesheetsFromCDN' ]),
56
-            new \Twig_SimpleFunction('isWMFLabs', [ $this, 'isWMFLabs' ]),
57
-            new \Twig_SimpleFunction('replag', [ $this, 'replag' ]),
58
-            new \Twig_SimpleFunction('link', [ $this, 'link' ]),
59
-            new \Twig_SimpleFunction('quote', [ $this, 'quote' ]),
60
-            new \Twig_SimpleFunction('bugReportURL', [ $this, 'bugReportURL' ]),
35
+            new \Twig_SimpleFunction('request_time', [$this, 'requestTime'], $options),
36
+            new \Twig_SimpleFunction('memory_usage', [$this, 'requestMemory'], $options),
37
+            new \Twig_SimpleFunction('year', [$this, 'generateYear'], $options),
38
+            new \Twig_SimpleFunction('msgPrintExists', [$this, 'intuitionMessagePrintExists'], $options),
39
+            new \Twig_SimpleFunction('msgExists', [$this, 'intuitionMessageExists'], $options),
40
+            new \Twig_SimpleFunction('msg', [$this, 'intuitionMessage'], $options),
41
+            new \Twig_SimpleFunction('lang', [$this, 'getLang'], $options),
42
+            new \Twig_SimpleFunction('langName', [$this, 'getLangName'], $options),
43
+            new \Twig_SimpleFunction('allLangs', [$this, 'getAllLangs']),
44
+            new \Twig_SimpleFunction('isRTL', [$this, 'intuitionIsRTL']),
45
+            new \Twig_SimpleFunction('isRTLLang', [$this, 'intuitionIsRTLLang']),
46
+            new \Twig_SimpleFunction('shortHash', [$this, 'gitShortHash']),
47
+            new \Twig_SimpleFunction('hash', [$this, 'gitHash']),
48
+            new \Twig_SimpleFunction('enabled', [$this, 'tabEnabled']),
49
+            new \Twig_SimpleFunction('tools', [$this, 'allTools']),
50
+            new \Twig_SimpleFunction('color', [$this, 'getColorList']),
51
+            new \Twig_SimpleFunction('chartColor', [$this, 'chartColor']),
52
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
53
+            new \Twig_SimpleFunction('isSingleWiki', [$this, 'isSingleWiki']),
54
+            new \Twig_SimpleFunction('getReplagThreshold', [$this, 'getReplagThreshold']),
55
+            new \Twig_SimpleFunction('loadStylesheetsFromCDN', [$this, 'loadStylesheetsFromCDN']),
56
+            new \Twig_SimpleFunction('isWMFLabs', [$this, 'isWMFLabs']),
57
+            new \Twig_SimpleFunction('replag', [$this, 'replag']),
58
+            new \Twig_SimpleFunction('link', [$this, 'link']),
59
+            new \Twig_SimpleFunction('quote', [$this, 'quote']),
60
+            new \Twig_SimpleFunction('bugReportURL', [$this, 'bugReportURL']),
61 61
             new \Twig_SimpleFunction('logged_in_user', [$this, 'functionLoggedInUser']),
62 62
             new \Twig_SimpleFunction('isUserAnon', [$this, 'isUserAnon']),
63 63
             new \Twig_SimpleFunction('nsName', [$this, 'nsName']),
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function requestTime($decimals = 3)
74 74
     {
75
-        return number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], $decimals);
75
+        return number_format(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], $decimals);
76 76
     }
77 77
 
78 78
     /**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function intuitionMessageExists($message = "")
107 107
     {
108
-        return $this->getIntuition()->msgExists($message, [ "domain" => "xtools" ]);
108
+        return $this->getIntuition()->msgExists($message, ["domain" => "xtools"]);
109 109
     }
110 110
 
111 111
     /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public function intuitionMessage($message = "", $vars = [])
138 138
     {
139
-        return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]);
139
+        return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]);
140 140
     }
141 141
 
142 142
     /**
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function getAllLangs()
167 167
     {
168
-        $messageFiles = glob($this->container->getParameter("kernel.root_dir") . '/../i18n/*.json');
168
+        $messageFiles = glob($this->container->getParameter("kernel.root_dir").'/../i18n/*.json');
169 169
 
170 170
         $languages = array_values(array_unique(array_map(
171
-            function ($filename) {
171
+            function($filename) {
172 172
                 return basename($filename, '.json');
173 173
             },
174 174
             $messageFiles
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
     public function getFilters()
517 517
     {
518 518
         return [
519
-            new \Twig_SimpleFilter('capitalize_first', [ $this, 'capitalizeFirst' ]),
520
-            new \Twig_SimpleFilter('percent_format', [ $this, 'percentFormat' ]),
521
-            new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]),
519
+            new \Twig_SimpleFilter('capitalize_first', [$this, 'capitalizeFirst']),
520
+            new \Twig_SimpleFilter('percent_format', [$this, 'percentFormat']),
521
+            new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]),
522 522
         ];
523 523
     }
524 524
 
@@ -545,10 +545,10 @@  discard block
 block discarded – undo
545 545
         if (!$denominator) {
546 546
             $quotient = $numerator;
547 547
         } else {
548
-            $quotient = ( $numerator / $denominator ) * 100;
548
+            $quotient = ($numerator / $denominator) * 100;
549 549
         }
550 550
 
551
-        return round($quotient, $precision) . '%';
551
+        return round($quotient, $precision).'%';
552 552
     }
553 553
 
554 554
     /**
@@ -623,20 +623,20 @@  discard block
 block discarded – undo
623 623
 
624 624
         if ($seconds >= 86400) {
625 625
             // Over a day
626
-            $val = (int) floor($seconds / 86400);
626
+            $val = (int)floor($seconds / 86400);
627 627
             $key = 'days';
628 628
         } elseif ($seconds >= 3600) {
629 629
             // Over an hour, less than a day
630
-            $val = (int) floor($seconds / 3600);
630
+            $val = (int)floor($seconds / 3600);
631 631
             $key = 'hours';
632 632
         } elseif ($seconds >= 60) {
633 633
             // Over a minute, less than an hour
634
-            $val = (int) floor($seconds / 60);
634
+            $val = (int)floor($seconds / 60);
635 635
             $key = 'minutes';
636 636
         }
637 637
 
638 638
         if ($translate) {
639
-            return number_format($val) . ' ' . $this->intuitionMessage("num-$key", [$val]);
639
+            return number_format($val).' '.$this->intuitionMessage("num-$key", [$val]);
640 640
         } else {
641 641
             return [number_format($val), "num-$key"];
642 642
         }
Please login to merge, or discard this patch.