@@ -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 AppBundle\EventSubscriber; |
9 | 9 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $cacheItem = $this->cache->getItem($cacheKey); |
125 | 125 | |
126 | 126 | // If increment value already in cache, or start with 1. |
127 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
127 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
128 | 128 | |
129 | 129 | // Check if limit has been exceeded, and if so, throw an error. |
130 | 130 | if ($count > $this->rateLimit) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $cacheItem = $this->cache->getItem($cacheKey); |
165 | 165 | |
166 | 166 | // If increment value already in cache, or start with 1. |
167 | - $count = $cacheItem->isHit() ? (int)$cacheItem->get() + 1 : 1; |
|
167 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
168 | 168 | |
169 | 169 | // Check if limit has been exceeded, and if so, add a log entry. |
170 | 170 | if ($count > 3) { |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | $message = $this->i18n->msg('error-rate-limit', [ |
240 | 240 | $this->rateDuration, |
241 | 241 | "<a href='/login'>".$this->i18n->msg('error-rate-limit-login')."</a>", |
242 | - "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>" . |
|
243 | - $this->i18n->msg('api') . |
|
242 | + "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>". |
|
243 | + $this->i18n->msg('api'). |
|
244 | 244 | "</a>", |
245 | 245 | ]); |
246 | 246 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the Repository class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Repository; |
9 | 9 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | // $tableExtension in order to generate the new table name |
167 | 167 | if ($this->isLabs() && null !== $tableExtension) { |
168 | 168 | $mapped = true; |
169 | - $tableName .=('' === $tableExtension ? '' : '_'.$tableExtension); |
|
169 | + $tableName .= ('' === $tableExtension ? '' : '_'.$tableExtension); |
|
170 | 170 | } elseif ($this->container->hasParameter("app.table.$tableName")) { |
171 | 171 | // Use the table specified in the table mapping configuration, if present. |
172 | 172 | $mapped = true; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | // This is a safeguard in case table mapping isn't properly set up. |
179 | 179 | $isLoggingOrRevision = in_array($tableName, ['revision', 'logging', 'archive']); |
180 | 180 | if (!$mapped && $isLoggingOrRevision && $this->isLabs()) { |
181 | - $tableName .="_userindex"; |
|
181 | + $tableName .= "_userindex"; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | // Figure out database name. |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | $rendered = str_replace('"', '\"', trim($rendered)); |
104 | 104 | |
105 | 105 | // Uglify temporary file. |
106 | - $tmpFile = sys_get_temp_dir() . '/xtools_articleinfo_gadget.js'; |
|
106 | + $tmpFile = sys_get_temp_dir().'/xtools_articleinfo_gadget.js'; |
|
107 | 107 | $script = "echo \"$rendered\" | tee $tmpFile >/dev/null && "; |
108 | 108 | $script .= $this->get('kernel')->getProjectDir(). |
109 | - "/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle " . |
|
109 | + "/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle ". |
|
110 | 110 | "&& rm $tmpFile >/dev/null"; |
111 | 111 | $process = new Process([$script]); |
112 | 112 | $process->run(); |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | $rendered = str_replace('\"', '"', trim($rendered)); |
125 | 125 | |
126 | 126 | // Add comment after uglifying since it removes comments. |
127 | - $rendered = "/**\n * This code was automatically generated and should not " . |
|
128 | - "be manually edited.\n * For updates, please copy and paste from " . |
|
129 | - $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL) . |
|
130 | - "\n * Released under GPL v3 license.\n */\n" . $rendered; |
|
127 | + $rendered = "/**\n * This code was automatically generated and should not ". |
|
128 | + "be manually edited.\n * For updates, please copy and paste from ". |
|
129 | + $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL). |
|
130 | + "\n * Released under GPL v3 license.\n */\n".$rendered; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $response = new Response($rendered); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the Edit class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Model; |
9 | 9 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public static function getEditsFromRevs(Project $project, User $user, array $revs): array |
88 | 88 | { |
89 | - return array_map(function ($rev) use ($project, $user) { |
|
89 | + return array_map(function($rev) use ($project, $user) { |
|
90 | 90 | /** @var Page $page Page object to be passed to the Edit constructor. */ |
91 | 91 | $page = Page::newFromRev($project, $rev); |
92 | 92 | $rev['user'] = $user; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $isSection = preg_match_all("/^\/\* (.*?) \*\//", $summary, $sectionMatch); |
300 | 300 | |
301 | 301 | if ($isSection && isset($page)) { |
302 | - $pageUrl = $project->getUrl(false) . str_replace( |
|
302 | + $pageUrl = $project->getUrl(false).str_replace( |
|
303 | 303 | '$1', |
304 | 304 | $page->getTitle($useUnnormalizedPageTitle), |
305 | 305 | $project->getArticlePath() |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | // Must have underscores for the link to properly go to the section. |
310 | 310 | $sectionTitleLink = htmlspecialchars(str_replace(' ', '_', $sectionTitle)); |
311 | 311 | |
312 | - $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>" . |
|
313 | - "<em class='text-muted'>" . htmlspecialchars($sectionTitle) . ":</em> "; |
|
312 | + $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>". |
|
313 | + "<em class='text-muted'>".htmlspecialchars($sectionTitle).":</em> "; |
|
314 | 314 | $summary = str_replace($sectionMatch[0][0], $sectionWikitext, $summary); |
315 | 315 | } |
316 | 316 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | ); |
325 | 325 | |
326 | 326 | // Use normalized page title (underscored, capitalized). |
327 | - $pageUrl = $project->getUrl(false) . str_replace( |
|
327 | + $pageUrl = $project->getUrl(false).str_replace( |
|
328 | 328 | '$1', |
329 | 329 | ucfirst(str_replace(' ', '_', $wikiLinkPath)), |
330 | 330 | $project->getArticlePath() |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | public function getDiffUrl(): string |
363 | 363 | { |
364 | 364 | $project = $this->getProject(); |
365 | - $path = str_replace('$1', 'Special:Diff/' . $this->id, $project->getArticlePath()); |
|
366 | - return rtrim($project->getUrl(), '/') . $path; |
|
365 | + $path = str_replace('$1', 'Special:Diff/'.$this->id, $project->getArticlePath()); |
|
366 | + return rtrim($project->getUrl(), '/').$path; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | public function getPermaUrl(): string |
374 | 374 | { |
375 | 375 | $project = $this->getProject(); |
376 | - $path = str_replace('$1', 'Special:PermaLink/' . $this->id, $project->getArticlePath()); |
|
377 | - return rtrim($project->getUrl(), '/') . $path; |
|
376 | + $path = str_replace('$1', 'Special:PermaLink/'.$this->id, $project->getArticlePath()); |
|
377 | + return rtrim($project->getUrl(), '/').$path; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the CategoryEdits class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Model; |
9 | 9 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ) { |
47 | 47 | $this->project = $project; |
48 | 48 | $this->user = $user; |
49 | - $this->categories = array_map(function ($category) { |
|
49 | + $this->categories = array_map(function($category) { |
|
50 | 50 | return str_replace(' ', '_', $category); |
51 | 51 | }, $categories); |
52 | 52 | $this->start = false === $start ? '' : date('Y-m-d', $start); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getCategoriesNormalized(): array |
80 | 80 | { |
81 | - return array_map(function ($category) { |
|
81 | + return array_map(function($category) { |
|
82 | 82 | return str_replace('_', ' ', $category); |
83 | 83 | }, $this->categories); |
84 | 84 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the AdminStats class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Model; |
9 | 9 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $stats = $this->groupStatsByUsername($stats); |
97 | 97 | |
98 | 98 | // Resort, as for some reason the SQL doesn't do this properly. |
99 | - uasort($stats, function ($a, $b) { |
|
99 | + uasort($stats, function($a, $b) { |
|
100 | 100 | if ($a['total'] === $b['total']) { |
101 | 101 | return 0; |
102 | 102 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->usersAndGroups = $this->project->getUsersInGroups($groupUserGroups['local'], $groupUserGroups['global']); |
128 | 128 | |
129 | 129 | // Populate $this->usersInGroup with users who are in the relevant user group for $this->group. |
130 | - $this->usersInGroup = array_keys(array_filter($this->usersAndGroups, function ($groups) { |
|
130 | + $this->usersInGroup = array_keys(array_filter($this->usersAndGroups, function($groups) { |
|
131 | 131 | return in_array($this->getRelevantUserGroup(), $groups); |
132 | 132 | })); |
133 | 133 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | if ($wikiPath) { |
153 | - $out = array_map(function ($url) { |
|
153 | + $out = array_map(function($url) { |
|
154 | 154 | return str_replace('.svg.png', '.svg', preg_replace('/.*\/18px-/', '', $url)); |
155 | 155 | }, $out); |
156 | 156 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function numDays(): int |
166 | 166 | { |
167 | - return (int)(($this->end - $this->start) / 60 / 60 / 24); |
|
167 | + return (int)(($this->end-$this->start) / 60 / 60 / 24); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -254,6 +254,6 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function getNumWithActionsNotInGroup(): int |
256 | 256 | { |
257 | - return count($this->adminStats) - $this->numWithActions; |
|
257 | + return count($this->adminStats)-$this->numWithActions; |
|
258 | 258 | } |
259 | 259 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the AutoEdits class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Model; |
9 | 9 | |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | public function getToolsTotal(): int |
226 | 226 | { |
227 | 227 | if (!is_int($this->toolsTotal)) { |
228 | - $this->toolsTotal = array_reduce($this->getToolCounts(), function ($a, $b) { |
|
229 | - return $a + $b['count']; |
|
228 | + $this->toolsTotal = array_reduce($this->getToolCounts(), function($a, $b) { |
|
229 | + return $a+$b['count']; |
|
230 | 230 | }); |
231 | 231 | } |
232 | 232 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the AppExtension class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Twig; |
9 | 9 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function requestTime(): float |
113 | 113 | { |
114 | 114 | if (!isset($this->requestTime)) { |
115 | - $this->requestTime = microtime(true) - $this->getRequest()->server->get('REQUEST_TIME_FLOAT'); |
|
115 | + $this->requestTime = microtime(true)-$this->getRequest()->server->get('REQUEST_TIME_FLOAT'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $this->requestTime; |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | } |
552 | 552 | |
553 | 553 | $sizeMessage = $this->numberFormat( |
554 | - pow(1024, $base - floor($base)), |
|
554 | + pow(1024, $base-floor($base)), |
|
555 | 555 | $precision |
556 | 556 | ); |
557 | 557 | |
@@ -708,15 +708,15 @@ discard block |
||
708 | 708 | |
709 | 709 | if ($seconds >= 86400) { |
710 | 710 | // Over a day |
711 | - $val = (int) floor($seconds / 86400); |
|
711 | + $val = (int)floor($seconds / 86400); |
|
712 | 712 | $key = 'days'; |
713 | 713 | } elseif ($seconds >= 3600) { |
714 | 714 | // Over an hour, less than a day |
715 | - $val = (int) floor($seconds / 3600); |
|
715 | + $val = (int)floor($seconds / 3600); |
|
716 | 716 | $key = 'hours'; |
717 | 717 | } elseif ($seconds >= 60) { |
718 | 718 | // Over a minute, less than an hour |
719 | - $val = (int) floor($seconds / 60); |
|
719 | + $val = (int)floor($seconds / 60); |
|
720 | 720 | $key = 'minutes'; |
721 | 721 | } |
722 | 722 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * This file contains only the AutoEditsRepository class. |
4 | 4 | */ |
5 | 5 | |
6 | -declare(strict_types = 1); |
|
6 | +declare(strict_types=1); |
|
7 | 7 | |
8 | 8 | namespace AppBundle\Repository; |
9 | 9 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | if ('all' !== $namespace) { |
38 | 38 | // Limit by namespace. |
39 | - return array_filter($this->aeTools, function (array $tool) use ($namespace) { |
|
39 | + return array_filter($this->aeTools, function(array $tool) use ($namespace) { |
|
40 | 40 | return empty($tool['namespaces']) || |
41 | 41 | in_array((int)$namespace, $tool['namespaces']) || |
42 | 42 | ( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $tagJoin = "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id"; |
92 | 92 | $condTools[] = "ct_tag_id IN ($tagIds)"; |
93 | 93 | } |
94 | - $condTool = 'AND (' . implode(' OR ', $condTools) . ')'; |
|
94 | + $condTool = 'AND ('.implode(' OR ', $condTools).')'; |
|
95 | 95 | |
96 | 96 | $sql = "SELECT COUNT(DISTINCT(rev_id)) |
97 | 97 | FROM $revisionTable |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | } |
312 | 312 | |
313 | 313 | // Sort the array by count |
314 | - uasort($results, function ($a, $b) { |
|
315 | - return $b['count'] - $a['count']; |
|
314 | + uasort($results, function($a, $b) { |
|
315 | + return $b['count']-$a['count']; |
|
316 | 316 | }); |
317 | 317 | |
318 | 318 | // Cache and return. |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | if (isset($values['tags'])) { |
485 | 485 | $tags = array_merge( |
486 | 486 | $tags, |
487 | - array_map(function ($tag) use ($conn) { |
|
487 | + array_map(function($tag) use ($conn) { |
|
488 | 488 | return $conn->quote($tag, \PDO::PARAM_STR); |
489 | 489 | }, $values['tags']) |
490 | 490 | ); |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | |
519 | 519 | if ($tagExcludes && 1 === count($tagIds)) { |
520 | 520 | // Get tag IDs, filtering out those for which no ID exists (meaning there is no local tag for that tool). |
521 | - $excludesList = implode(',', array_filter(array_map(function ($tagName) use ($project) { |
|
521 | + $excludesList = implode(',', array_filter(array_map(function($tagName) use ($project) { |
|
522 | 522 | return $this->getTags($project)[$tagName] ?? null; |
523 | 523 | }, $tagExcludes))); |
524 | 524 |