@@ -5,12 +5,9 @@ |
||
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 | 9 | use Symfony\Component\HttpFoundation\Request; |
12 | 10 | use Symfony\Component\HttpFoundation\Response; |
13 | -use Symfony\Component\Debug\Exception\FatalErrorException; |
|
14 | 11 | use FOS\RestBundle\Controller\Annotations as Rest; |
15 | 12 | use FOS\RestBundle\Controller\FOSRestController; |
16 | 13 | use FOS\RestBundle\View\View; |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | $view = View::create()->setStatusCode(Response::HTTP_OK); |
118 | 118 | |
119 | 119 | if ($request->query->get('format') === 'html') { |
120 | - $edits = array_map(function ($attrs) use ($project, $username) { |
|
120 | + $edits = array_map(function($attrs) use ($project, $username) { |
|
121 | 121 | $nsName = ''; |
122 | 122 | if ($attrs['page_namespace']) { |
123 | 123 | $nsName = $project->getNamespaces()[$attrs['page_namespace']]; |
124 | 124 | } |
125 | 125 | $page = $project->getRepository() |
126 | - ->getPage($project, $nsName . ':' . $attrs['page_title']); |
|
126 | + ->getPage($project, $nsName.':'.$attrs['page_title']); |
|
127 | 127 | $attrs['id'] = $attrs['rev_id']; |
128 | 128 | $attrs['username'] = $username; |
129 | 129 | return new Edit($page, $attrs); |
@@ -180,19 +180,19 @@ discard block |
||
180 | 180 | $info = $page->getBasicEditingInfo(); |
181 | 181 | $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']); |
182 | 182 | $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']); |
183 | - $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp(); |
|
183 | + $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp(); |
|
184 | 184 | |
185 | 185 | $data = [ |
186 | - 'revisions' => (int) $info['num_edits'], |
|
187 | - 'editors' => (int) $info['num_editors'], |
|
186 | + 'revisions' => (int)$info['num_edits'], |
|
187 | + 'editors' => (int)$info['num_editors'], |
|
188 | 188 | 'author' => $info['author'], |
189 | - 'author_editcount' => (int) $info['author_editcount'], |
|
189 | + 'author_editcount' => (int)$info['author_editcount'], |
|
190 | 190 | 'created_at' => $creationDateTime->format('Y-m-d'), |
191 | 191 | 'created_rev_id' => $info['created_rev_id'], |
192 | 192 | 'modified_at' => $modifiedDateTime->format('Y-m-d H:i'), |
193 | 193 | 'secs_since_last_edit' => $secsSinceLastEdit, |
194 | - 'last_edit_id' => (int) $info['modified_rev_id'], |
|
195 | - 'watchers' => (int) $page->getWatchers(), |
|
194 | + 'last_edit_id' => (int)$info['modified_rev_id'], |
|
195 | + 'watchers' => (int)$page->getWatchers(), |
|
196 | 196 | 'pageviews' => $page->getLastPageviews($pageviewsOffset), |
197 | 197 | 'pageviews_offset' => $pageviewsOffset, |
198 | 198 | ]; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | $conn = $this->getDoctrine()->getManager('default')->getConnection(); |
250 | - $date = date('Y-m-d'); |
|
250 | + $date = date('Y-m-d'); |
|
251 | 251 | |
252 | 252 | // Increment count in timeline |
253 | 253 | $existsSql = "SELECT 1 FROM usage_timeline |
@@ -59,7 +59,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
420 | 420 | |
421 | 421 | /** |
422 | 422 | * Get the sum of pageviews 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) |
@@ -183,7 +183,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | return 0; |
434 | 434 | } |
435 | 435 | |
436 | - return array_sum(array_map(function ($item) { |
|
437 | - return (int) $item['views']; |
|
436 | + return array_sum(array_map(function($item) { |
|
437 | + return (int)$item['views']; |
|
438 | 438 | }, $pageviews['items'])); |
439 | 439 | } |
440 | 440 |