@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the TopEdits class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace App\Model; |
9 | 9 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | $firstDateTime = $this->topEdits[0]->getTimestamp(); |
159 | 159 | $lastDateTime = end($this->topEdits)->getTimestamp(); |
160 | - $secs = $firstDateTime->getTimestamp() - $lastDateTime->getTimestamp(); |
|
160 | + $secs = $firstDateTime->getTimestamp()-$lastDateTime->getTimestamp(); |
|
161 | 161 | $days = $secs / (60 * 60 * 24); |
162 | 162 | return $days / count($this->topEdits); |
163 | 163 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the User class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace App\Model; |
9 | 9 | |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | $firstAddrUnpacked = unpack('H*', $firstAddrBin); |
128 | 128 | $firstAddrHex = reset($firstAddrUnpacked); |
129 | 129 | $range[0] = inet_ntop($firstAddrBin); |
130 | - $flexBits = 128 - $prefixLen; |
|
130 | + $flexBits = 128-$prefixLen; |
|
131 | 131 | $lastAddrHex = $firstAddrHex; |
132 | 132 | |
133 | 133 | $pos = 31; |
134 | 134 | while ($flexBits > 0) { |
135 | 135 | $orig = substr($lastAddrHex, $pos, 1); |
136 | 136 | $origVal = hexdec($orig); |
137 | - $newVal = $origVal | (pow(2, min(4, $flexBits)) - 1); |
|
137 | + $newVal = $origVal | (pow(2, min(4, $flexBits))-1); |
|
138 | 138 | $new = dechex($newVal); |
139 | 139 | $lastAddrHex = substr_replace($lastAddrHex, $new, $pos, 1); |
140 | 140 | $flexBits -= 4; |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | $range[1] = inet_ntop($lastAddrBin); |
146 | 146 | } else { |
147 | 147 | $cidr = explode('/', $this->username); |
148 | - $range[0] = long2ip(ip2long($cidr[0]) & -1 << (32 - (int)$cidr[1])); |
|
149 | - $range[1] = long2ip(ip2long($range[0]) + pow(2, (32 - (int)$cidr[1])) - 1); |
|
148 | + $range[0] = long2ip(ip2long($cidr[0]) & -1 << (32-(int)$cidr[1])); |
|
149 | + $range[1] = long2ip(ip2long($range[0])+pow(2, (32-(int)$cidr[1]))-1); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // Find the leftmost common characters between the two addresses. |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function countEdits(Project $project, $namespace = 'all', $start = false, $end = false): int |
356 | 356 | { |
357 | - return (int) $this->getRepository()->countEdits($project, $this, $namespace, $start, $end); |
|
357 | + return (int)$this->getRepository()->countEdits($project, $this, $namespace, $start, $end); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | |
4 | 4 | namespace App\Model; |
5 | 5 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function getMaxRevisions(): int |
93 | 93 | { |
94 | 94 | if (!isset($this->maxRevisions)) { |
95 | - $this->maxRevisions = (int) $this->container->getParameter('app.max_page_revisions'); |
|
95 | + $this->maxRevisions = (int)$this->container->getParameter('app.max_page_revisions'); |
|
96 | 96 | } |
97 | 97 | return $this->maxRevisions; |
98 | 98 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $refs = $crawler->filter('#mw-content-text .reference'); |
174 | 174 | $refContent = []; |
175 | - $refs->each(function ($ref) use (&$refContent): void { |
|
175 | + $refs->each(function($ref) use (&$refContent): void { |
|
176 | 176 | $refContent[] = $ref->text(); |
177 | 177 | }); |
178 | 178 | $uniqueRefs = count(array_unique($refContent)); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $totalChars = 0; |
201 | 201 | $totalWords = 0; |
202 | 202 | $paragraphs = $crawler->filter($selector); |
203 | - $paragraphs->each(function ($node) use (&$totalChars, &$totalWords): void { |
|
203 | + $paragraphs->each(function($node) use (&$totalChars, &$totalWords): void { |
|
204 | 204 | /** @var Crawler $node */ |
205 | 205 | $text = preg_replace('/\[\d+]/', '', trim($node->text(null, true))); |
206 | 206 | $totalChars += strlen($text); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $data = [ |
265 | 265 | 'project' => $project->getDomain(), |
266 | 266 | 'page' => $page->getTitle(), |
267 | - 'watchers' => (int) $page->getWatchers(), |
|
267 | + 'watchers' => (int)$page->getWatchers(), |
|
268 | 268 | 'pageviews' => $page->getLastPageviews($pageviewsOffset), |
269 | 269 | 'pageviews_offset' => $pageviewsOffset, |
270 | 270 | ]; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | if (false !== $info) { |
290 | 290 | $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']); |
291 | 291 | $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']); |
292 | - $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp(); |
|
292 | + $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp(); |
|
293 | 293 | |
294 | 294 | // Some wikis (such foundation.wikimedia.org) may be missing the creation date. |
295 | 295 | $creationDateTime = false === $creationDateTime |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | ->getAssessment($page); |
302 | 302 | |
303 | 303 | $data = array_merge($data, [ |
304 | - 'revisions' => (int) $info['num_edits'], |
|
305 | - 'editors' => (int) $info['num_editors'], |
|
306 | - 'minor_edits' => (int) $info['minor_edits'], |
|
304 | + 'revisions' => (int)$info['num_edits'], |
|
305 | + 'editors' => (int)$info['num_editors'], |
|
306 | + 'minor_edits' => (int)$info['minor_edits'], |
|
307 | 307 | 'author' => $info['author'], |
308 | - 'author_editcount' => null === $info['author_editcount'] ? null : (int) $info['author_editcount'], |
|
308 | + 'author_editcount' => null === $info['author_editcount'] ? null : (int)$info['author_editcount'], |
|
309 | 309 | 'created_at' => $creationDateTime, |
310 | 310 | 'created_rev_id' => $info['created_rev_id'], |
311 | 311 | 'modified_at' => $modifiedDateTime->format('Y-m-d H:i'), |
312 | 312 | 'secs_since_last_edit' => $secsSinceLastEdit, |
313 | - 'last_edit_id' => (int) $info['modified_rev_id'], |
|
313 | + 'last_edit_id' => (int)$info['modified_rev_id'], |
|
314 | 314 | 'assessment' => $assessment, |
315 | 315 | ]); |
316 | 316 | } |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | } |
463 | 463 | |
464 | 464 | // Sort by edit count. |
465 | - uasort($this->bots, function ($a, $b) { |
|
466 | - return $b['count'] - $a['count']; |
|
465 | + uasort($this->bots, function($a, $b) { |
|
466 | + return $b['count']-$a['count']; |
|
467 | 467 | }); |
468 | 468 | |
469 | 469 | return $this->bots; |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the I18nHelper. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace App\Helper; |
9 | 9 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | // Find the path, and complain if English doesn't exist. |
77 | - $path = $this->container->getParameter('kernel.root_dir') . '/../i18n'; |
|
77 | + $path = $this->container->getParameter('kernel.root_dir').'/../i18n'; |
|
78 | 78 | if (!file_exists("$path/en.json")) { |
79 | 79 | throw new Exception("Language directory doesn't exist: $path"); |
80 | 80 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $messageFiles = glob($this->container->getParameter('kernel.root_dir').'/../i18n/*.json'); |
130 | 130 | |
131 | 131 | $languages = array_values(array_unique(array_map( |
132 | - function ($filename) { |
|
132 | + function($filename) { |
|
133 | 133 | return basename($filename, '.json'); |
134 | 134 | }, |
135 | 135 | $messageFiles |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $this->getIntuition()->getLangFallbacks($this->getLang()) |
172 | 172 | ); |
173 | 173 | |
174 | - return array_filter($fallbacks, function ($lang) use ($i18nPath) { |
|
174 | + return array_filter($fallbacks, function($lang) use ($i18nPath) { |
|
175 | 175 | return is_file($i18nPath.$lang.'.json'); |
176 | 176 | }); |
177 | 177 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the AutomatedEditsHelper class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace App\Helper; |
9 | 9 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | $session = $this->container->get('session'); |
88 | - $uri = 'https://meta.wikimedia.org/w/index.php?action=raw&ctype=application/json&title=' . |
|
89 | - 'MediaWiki:XTools-AutoEdits.json' . ($useSandbox ? '/sandbox' : ''); |
|
88 | + $uri = 'https://meta.wikimedia.org/w/index.php?action=raw&ctype=application/json&title='. |
|
89 | + 'MediaWiki:XTools-AutoEdits.json'.($useSandbox ? '/sandbox' : ''); |
|
90 | 90 | |
91 | 91 | if ($useSandbox && $session->get('logged_in_user')) { |
92 | 92 | // Request via OAuth to get around server-side caching. |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | |
150 | 150 | // Once last walk through for some tidying up and validation. |
151 | 151 | $invalid = []; |
152 | - array_walk($this->tools[$projectDomain], function (&$data, $tool) use (&$invalid): void { |
|
152 | + array_walk($this->tools[$projectDomain], function(&$data, $tool) use (&$invalid): void { |
|
153 | 153 | // Populate the 'label' with the tool name, if a label doesn't already exist. |
154 | 154 | $data['label'] = $data['label'] ?? $tool; |
155 | 155 | |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | |
234 | 234 | $revertEntries = array_filter( |
235 | 235 | $this->getTools($project), |
236 | - function ($tool) { |
|
236 | + function($tool) { |
|
237 | 237 | return isset($tool['revert']) && isset($tool['regex']); |
238 | 238 | } |
239 | 239 | ); |
240 | 240 | |
241 | 241 | // If 'revert' is set to `true`, then use 'regex' as the regular expression, |
242 | 242 | // otherwise 'revert' is assumed to be the regex string. |
243 | - $this->revertTools[$projectDomain] = array_map(function ($revertTool) { |
|
243 | + $this->revertTools[$projectDomain] = array_map(function($revertTool) { |
|
244 | 244 | return [ |
245 | 245 | 'link' => $revertTool['link'], |
246 | 246 | 'regex' => true === $revertTool['revert'] ? $revertTool['regex'] : $revertTool['revert'], |
@@ -3,7 +3,7 @@ |
||
3 | 3 | * This file contains only the WebProcessorMonolog class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace App\Monolog; |
9 | 9 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | |
4 | 4 | namespace App\DoctrineMigrations; |
5 | 5 |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -declare(strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * This file contains only the ExceptionListener class. |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the RateLimitSubscriber class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace App\EventSubscriber; |
9 | 9 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $cacheItem = $this->cache->getItem($cacheKey); |
144 | 144 | |
145 | 145 | // If increment value already in cache, or start with 1. |
146 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
146 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
147 | 147 | |
148 | 148 | // Check if limit has been exceeded, and if so, throw an error. |
149 | 149 | if ($count > $this->rateLimit) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $cacheItem = $this->cache->getItem($cacheKey); |
184 | 184 | |
185 | 185 | // If increment value already in cache, or start with 1. |
186 | - $count = $cacheItem->isHit() ? (int)$cacheItem->get() + 1 : 1; |
|
186 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
187 | 187 | |
188 | 188 | // Check if limit has been exceeded, and if so, add a log entry. |
189 | 189 | if ($count > 3) { |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | $message = $this->i18n->msg('error-rate-limit', [ |
259 | 259 | $this->rateDuration, |
260 | 260 | "<a href='/login'>".$this->i18n->msg('error-rate-limit-login')."</a>", |
261 | - "<a href='https://www.mediawiki.org/wiki/Special:MyLanguage/XTools/API' target='_blank'>" . |
|
262 | - $this->i18n->msg('api') . |
|
261 | + "<a href='https://www.mediawiki.org/wiki/Special:MyLanguage/XTools/API' target='_blank'>". |
|
262 | + $this->i18n->msg('api'). |
|
263 | 263 | "</a>", |
264 | 264 | ]); |
265 | 265 |