@@ -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 AppBundle\Helper; |
| 9 | 9 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | // Finally, populate the 'label' with the tool name, if a label doesn't already exist. |
| 99 | - array_walk($this->tools[$projectDomain], function (&$data, $tool): void { |
|
| 99 | + array_walk($this->tools[$projectDomain], function(&$data, $tool): void { |
|
| 100 | 100 | $data['label'] = $data['label'] ?? $tool; |
| 101 | 101 | |
| 102 | 102 | // 'namespaces' should be an array of ints. |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $revertEntries = array_filter( |
| 165 | 165 | $this->getTools($project), |
| 166 | - function ($tool) { |
|
| 166 | + function($tool) { |
|
| 167 | 167 | return isset($tool['revert']); |
| 168 | 168 | } |
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | 171 | // If 'revert' is set to `true`, then use 'regex' as the regular expression, |
| 172 | 172 | // otherwise 'revert' is assumed to be the regex string. |
| 173 | - $this->revertTools[$projectDomain] = array_map(function ($revertTool) { |
|
| 173 | + $this->revertTools[$projectDomain] = array_map(function($revertTool) { |
|
| 174 | 174 | return [ |
| 175 | 175 | 'link' => $revertTool['link'], |
| 176 | 176 | 'regex' => true === $revertTool['revert'] ? $revertTool['regex'] : $revertTool['revert'], |
@@ -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 | ( |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $tagJoin = "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id"; |
| 104 | 104 | $condTools[] = "ct_tag_id IN ($tagIds)"; |
| 105 | 105 | } |
| 106 | - $condTool = 'AND (' . implode(' OR ', $condTools) . ')'; |
|
| 106 | + $condTool = 'AND ('.implode(' OR ', $condTools).')'; |
|
| 107 | 107 | $userClause = $user->isAnon() ? 'rev_user_text = :username' : 'rev_user = :userId'; |
| 108 | 108 | |
| 109 | 109 | $sql = "SELECT COUNT(DISTINCT(rev_id)) |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Sort the array by count |
| 342 | - uasort($results, function ($a, $b) { |
|
| 343 | - return $b['count'] - $a['count']; |
|
| 342 | + uasort($results, function($a, $b) { |
|
| 343 | + return $b['count']-$a['count']; |
|
| 344 | 344 | }); |
| 345 | 345 | |
| 346 | 346 | // Cache and return. |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | if ('' === $condTool) { |
| 445 | 445 | $condTool = $tagClause; |
| 446 | 446 | } else { |
| 447 | - $condTool = '(' . $condTool . " OR $tagClause)"; |
|
| 447 | + $condTool = '('.$condTool." OR $tagClause)"; |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
@@ -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 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function onKernelController(FilterControllerEvent $event): void |
| 65 | 65 | { |
| 66 | - $this->rateLimit = (int) $this->container->getParameter('app.rate_limit_count'); |
|
| 67 | - $this->rateDuration = (int) $this->container->getParameter('app.rate_limit_time'); |
|
| 66 | + $this->rateLimit = (int)$this->container->getParameter('app.rate_limit_count'); |
|
| 67 | + $this->rateDuration = (int)$this->container->getParameter('app.rate_limit_time'); |
|
| 68 | 68 | $request = $event->getRequest(); |
| 69 | 69 | |
| 70 | 70 | // Zero values indicate the rate limiting feature should be disabled. |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $controller = $event->getController(); |
| 76 | - $loggedIn = (bool) $this->container->get('session')->get('logged_in_user'); |
|
| 76 | + $loggedIn = (bool)$this->container->get('session')->get('logged_in_user'); |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Rate limiting will not apply to these actions |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $cacheItem = $cache->getItem($cacheKey); |
| 100 | 100 | |
| 101 | 101 | // If increment value already in cache, or start with 1. |
| 102 | - $count = $cacheItem->isHit() ? (int) $cacheItem->get() + 1 : 1; |
|
| 102 | + $count = $cacheItem->isHit() ? (int)$cacheItem->get()+1 : 1; |
|
| 103 | 103 | |
| 104 | 104 | // Check if limit has been exceeded, and if so, throw an error. |
| 105 | 105 | if ($count > $this->rateLimit) { |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | // Log the denied request |
| 131 | 131 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 132 | 132 | $logger->info( |
| 133 | - "<URI>: " . $request->getRequestUri() . |
|
| 134 | - ('' != $logComment ? "\t<Reason>: $logComment" : '') . |
|
| 135 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 133 | + "<URI>: ".$request->getRequestUri(). |
|
| 134 | + ('' != $logComment ? "\t<Reason>: $logComment" : ''). |
|
| 135 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | 138 | throw new HttpException( |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | // Log the denied request |
| 165 | 165 | $logger = $this->container->get('monolog.logger.rate_limit'); |
| 166 | 166 | $logger->info( |
| 167 | - "<URI>: " . $request->getRequestUri() . |
|
| 168 | - ('' != $logComment ? "\t<Reason>: $logComment" : '') . |
|
| 169 | - "\t<User agent>: " . $request->headers->get('User-Agent') |
|
| 167 | + "<URI>: ".$request->getRequestUri(). |
|
| 168 | + ('' != $logComment ? "\t<Reason>: $logComment" : ''). |
|
| 169 | + "\t<User agent>: ".$request->headers->get('User-Agent') |
|
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | $message = $this->i18n->msg('error-rate-limit', [ |
| 173 | 173 | $this->rateDuration, |
| 174 | 174 | "<a href='/login'>".$this->i18n->msg('error-rate-limit-login')."</a>", |
| 175 | - "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>" . |
|
| 176 | - $this->i18n->msg('api') . |
|
| 175 | + "<a href='https://xtools.readthedocs.io/en/stable/api' target='_blank'>". |
|
| 176 | + $this->i18n->msg('api'). |
|
| 177 | 177 | "</a>", |
| 178 | 178 | ]); |
| 179 | 179 | |
@@ -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); |
| 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 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function numDays(): int |
| 157 | 157 | { |
| 158 | - return (int)(($this->end - $this->start) / 60 / 60 / 24); |
|
| 158 | + return (int)(($this->end-$this->start) / 60 / 60 / 24); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -245,6 +245,6 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | public function getNumWithActionsNotInGroup(): int |
| 247 | 247 | { |
| 248 | - return count($this->adminStats) - $this->numWithActions; |
|
| 248 | + return count($this->adminStats)-$this->numWithActions; |
|
| 249 | 249 | } |
| 250 | 250 | } |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | $actions = is_array($actionsQuery) ? $actionsQuery : explode('|', $actionsQuery); |
| 119 | 119 | |
| 120 | 120 | // Filter out any invalid section IDs. |
| 121 | - $actions = array_filter($actions, function ($action) use ($group) { |
|
| 121 | + $actions = array_filter($actions, function($action) use ($group) { |
|
| 122 | 122 | return in_array($action, $this->getActionNames($group)); |
| 123 | 123 | }); |
| 124 | 124 | |