@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace DoctrineMigrations; |
6 | 6 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace DoctrineMigrations; |
6 | 6 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace App\Model; |
6 | 6 | |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | $firstAddrUnpacked = unpack('H*', $firstAddrBin); |
127 | 127 | $firstAddrHex = reset($firstAddrUnpacked); |
128 | 128 | $range[0] = inet_ntop($firstAddrBin); |
129 | - $flexBits = 128 - $prefixLen; |
|
129 | + $flexBits = 128-$prefixLen; |
|
130 | 130 | $lastAddrHex = $firstAddrHex; |
131 | 131 | |
132 | 132 | $pos = 31; |
133 | 133 | while ($flexBits > 0) { |
134 | 134 | $orig = substr($lastAddrHex, $pos, 1); |
135 | 135 | $origVal = hexdec($orig); |
136 | - $newVal = $origVal | (pow(2, min(4, $flexBits)) - 1); |
|
136 | + $newVal = $origVal | (pow(2, min(4, $flexBits))-1); |
|
137 | 137 | $new = dechex($newVal); |
138 | 138 | $lastAddrHex = substr_replace($lastAddrHex, $new, $pos, 1); |
139 | 139 | $flexBits -= 4; |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | $range[1] = inet_ntop($lastAddrBin); |
145 | 145 | } else { |
146 | 146 | $cidr = explode('/', $this->username); |
147 | - $range[0] = long2ip(ip2long($cidr[0]) & -1 << (32 - (int)$cidr[1])); |
|
148 | - $range[1] = long2ip(ip2long($range[0]) + pow(2, (32 - (int)$cidr[1])) - 1); |
|
147 | + $range[0] = long2ip(ip2long($cidr[0]) & -1 << (32-(int)$cidr[1])); |
|
148 | + $range[1] = long2ip(ip2long($range[0])+pow(2, (32-(int)$cidr[1]))-1); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Find the leftmost common characters between the two addresses. |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $timeline = []; |
105 | 105 | $startObj = new DateTime($start); |
106 | 106 | $endObj = new DateTime($end); |
107 | - $numDays = (int) $endObj->diff($startObj)->format("%a"); |
|
107 | + $numDays = (int)$endObj->diff($startObj)->format("%a"); |
|
108 | 108 | $grandSum = 0; |
109 | 109 | |
110 | 110 | // Generate array of date labels |
@@ -114,17 +114,17 @@ discard block |
||
114 | 114 | |
115 | 115 | foreach ($data as $entry) { |
116 | 116 | if (!isset($totals[$entry['tool']])) { |
117 | - $totals[$entry['tool']] = (int) $entry['count']; |
|
117 | + $totals[$entry['tool']] = (int)$entry['count']; |
|
118 | 118 | |
119 | 119 | // Create arrays for each tool, filled with zeros for each date in the timeline |
120 | 120 | $timeline[$entry['tool']] = array_fill(0, $numDays, 0); |
121 | 121 | } else { |
122 | - $totals[$entry['tool']] += (int) $entry['count']; |
|
122 | + $totals[$entry['tool']] += (int)$entry['count']; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $date = new DateTime($entry['date']); |
126 | - $dateIndex = (int) $date->diff($startObj)->format("%a"); |
|
127 | - $timeline[$entry['tool']][$dateIndex] = (int) $entry['count']; |
|
126 | + $dateIndex = (int)$date->diff($startObj)->format("%a"); |
|
127 | + $timeline[$entry['tool']][$dateIndex] = (int)$entry['count']; |
|
128 | 128 | |
129 | 129 | $grandSum += $entry['count']; |
130 | 130 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $timeline = []; |
160 | 160 | $startObj = new DateTime($start); |
161 | 161 | $endObj = new DateTime($end); |
162 | - $numDays = (int) $endObj->diff($startObj)->format("%a"); |
|
162 | + $numDays = (int)$endObj->diff($startObj)->format("%a"); |
|
163 | 163 | $grandSum = 0; |
164 | 164 | |
165 | 165 | // Generate array of date labels |
@@ -169,17 +169,17 @@ discard block |
||
169 | 169 | |
170 | 170 | foreach ($data as $entry) { |
171 | 171 | if (!isset($totals[$entry['endpoint']])) { |
172 | - $totals[$entry['endpoint']] = (int) $entry['count']; |
|
172 | + $totals[$entry['endpoint']] = (int)$entry['count']; |
|
173 | 173 | |
174 | 174 | // Create arrays for each endpoint, filled with zeros for each date in the timeline |
175 | 175 | $timeline[$entry['endpoint']] = array_fill(0, $numDays, 0); |
176 | 176 | } else { |
177 | - $totals[$entry['endpoint']] += (int) $entry['count']; |
|
177 | + $totals[$entry['endpoint']] += (int)$entry['count']; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | $date = new DateTime($entry['date']); |
181 | - $dateIndex = (int) $date->diff($startObj)->format("%a"); |
|
182 | - $timeline[$entry['endpoint']][$dateIndex] = (int) $entry['count']; |
|
181 | + $dateIndex = (int)$date->diff($startObj)->format("%a"); |
|
182 | + $timeline[$entry['endpoint']][$dateIndex] = (int)$entry['count']; |
|
183 | 183 | |
184 | 184 | $grandSum += $entry['count']; |
185 | 185 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | /** @var Connection $conn */ |
241 | 241 | $conn = $managerRegistry->getConnection('default'); |
242 | - $date = date('Y-m-d'); |
|
242 | + $date = date('Y-m-d'); |
|
243 | 243 | |
244 | 244 | // Tool name needs to be lowercase. |
245 | 245 | $tool = strtolower($tool); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace App\Exception; |
6 | 6 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace App\Model; |
6 | 6 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $title = $info['title'] ?? $this->unnormalizedPageName; |
125 | 125 | $nsName = $this->getNamespaceName(); |
126 | 126 | return $nsName |
127 | - ? str_replace($nsName . ':', '', $title) |
|
127 | + ? str_replace($nsName.':', '', $title) |
|
128 | 128 | : $title; |
129 | 129 | } |
130 | 130 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | $content = $this->repository->getPagesWikitext( |
324 | 324 | $this->getProject(), |
325 | - [ $this->getTitle() ] |
|
325 | + [$this->getTitle()] |
|
326 | 326 | ); |
327 | 327 | |
328 | 328 | return $content[$this->getTitle()] ?? null; |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | |
389 | 389 | $wikidataInfo = $this->repository->getWikidataInfo($this); |
390 | 390 | |
391 | - $terms = array_map(function ($entry) { |
|
391 | + $terms = array_map(function($entry) { |
|
392 | 392 | return $entry['term']; |
393 | 393 | }, $wikidataInfo); |
394 | 394 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | 'prio' => 2, |
400 | 400 | 'name' => 'Wikidata', |
401 | 401 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
402 | - 'explanation' => "See: <a target='_blank' " . |
|
402 | + 'explanation' => "See: <a target='_blank' ". |
|
403 | 403 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
404 | 404 | ]; |
405 | 405 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | 'prio' => 3, |
410 | 410 | 'name' => 'Wikidata', |
411 | 411 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
412 | - 'explanation' => "See: <a target='_blank' " . |
|
412 | + 'explanation' => "See: <a target='_blank' ". |
|
413 | 413 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
414 | 414 | ]; |
415 | 415 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | return null; |
492 | 492 | } |
493 | 493 | |
494 | - return array_sum(array_map(function ($item) { |
|
494 | + return array_sum(array_map(function($item) { |
|
495 | 495 | return (int)$item['views']; |
496 | 496 | }, $pageviews['items'])); |
497 | 497 | } |
@@ -267,7 +267,7 @@ |
||
267 | 267 | $responseCode = Response::HTTP_OK; |
268 | 268 | $this->recordApiUsage('page/prose'); |
269 | 269 | $this->setupArticleInfo($articleInfoRepo, $autoEditsHelper); |
270 | - $this->addFlash('info', 'The algorithm used by this API has recently changed. ' . |
|
270 | + $this->addFlash('info', 'The algorithm used by this API has recently changed. '. |
|
271 | 271 | 'See https://www.mediawiki.org/wiki/XTools/Page_History#Prose for details.'); |
272 | 272 | $ret = $this->articleInfo->getProseStats(); |
273 | 273 | if (null === $ret) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace App\Repository; |
6 | 6 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | try { |
49 | 49 | $res = $this->guzzle->request('GET', $url, $opts); |
50 | - } catch (ServerException|ConnectException $e) { |
|
50 | + } catch (ServerException | ConnectException $e) { |
|
51 | 51 | throw new BadGatewayException('api-error-wikimedia', ['WikiWho'], $e); |
52 | 52 | } |
53 | 53 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace App\Repository; |
6 | 6 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | $wikidataId = ltrim($page->getWikidataId(), 'Q'); |
310 | 310 | |
311 | - $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . " |
|
311 | + $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')." |
|
312 | 312 | FROM wikidatawiki_p.wb_items_per_site |
313 | 313 | WHERE ips_item_id = :wikidataId"; |
314 | 314 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | 'wikidataId' => $wikidataId, |
317 | 317 | ])->fetchAllAssociative(); |
318 | 318 | |
319 | - return $count ? (int) $result[0]['count'] : $result; |
|
319 | + return $count ? (int)$result[0]['count'] : $result; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | // Transform to associative array by 'type' |
356 | 356 | foreach ($res as $row) { |
357 | - $data[$row['type'] . '_count'] = (int)$row['value']; |
|
357 | + $data[$row['type'].'_count'] = (int)$row['value']; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $data; |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | |
406 | 406 | $project = $page->getProject()->getDomain(); |
407 | 407 | |
408 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . |
|
408 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. |
|
409 | 409 | "$project/all-access/user/$title/daily/$start/$end"; |
410 | 410 | |
411 | 411 | try { |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | ]); |
416 | 416 | $pageviews = json_decode($res->getBody()->getContents(), true); |
417 | 417 | return $pageviews; |
418 | - } catch (ServerException|ConnectException $e) { |
|
418 | + } catch (ServerException | ConnectException $e) { |
|
419 | 419 | throw new BadGatewayException('api-error-wikimedia', ['Pageviews'], $e); |
420 | 420 | } |
421 | 421 | } |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | { |
432 | 432 | if ($this->isWMF) { |
433 | 433 | $domain = $page->getProject()->getDomain(); |
434 | - $url = "https://$domain/api/rest_v1/page/html/" . urlencode(str_replace(' ', '_', $page->getTitle())); |
|
434 | + $url = "https://$domain/api/rest_v1/page/html/".urlencode(str_replace(' ', '_', $page->getTitle())); |
|
435 | 435 | if (null !== $revId) { |
436 | 436 | $url .= "/$revId"; |
437 | 437 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | $normalized = []; |
506 | 506 | if (isset($result['query']['normalized'])) { |
507 | 507 | array_map( |
508 | - function ($e) use (&$normalized): void { |
|
508 | + function($e) use (&$normalized): void { |
|
509 | 509 | $normalized[$e['to']] = $e['from']; |
510 | 510 | }, |
511 | 511 | $result['query']['normalized'] |