@@ -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'] |
@@ -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 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'format' => 'json', |
197 | 197 | ], $params), |
198 | 198 | ])->getBody()->getContents(), true); |
199 | - } catch (ServerException|ConnectException $e) { |
|
199 | + } catch (ServerException | ConnectException $e) { |
|
200 | 200 | throw new BadGatewayException('api-error-wikimedia', ['Wikimedia'], $e); |
201 | 201 | } |
202 | 202 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | // $tableExtension in order to generate the new table name |
219 | 219 | if ($this->isWMF && null !== $tableExtension) { |
220 | 220 | $mapped = true; |
221 | - $tableName .=('' === $tableExtension ? '' : '_'.$tableExtension); |
|
221 | + $tableName .= ('' === $tableExtension ? '' : '_'.$tableExtension); |
|
222 | 222 | } elseif ($this->parameterBag->has("app.table.$tableName")) { |
223 | 223 | // Use the table specified in the table mapping configuration, if present. |
224 | 224 | $mapped = true; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | // This is a safeguard in case table mapping isn't properly set up. |
231 | 231 | $isLoggingOrRevision = in_array($tableName, ['revision', 'logging', 'archive']); |
232 | 232 | if (!$mapped && $isLoggingOrRevision && $this->isWMF) { |
233 | - $tableName .="_userindex"; |
|
233 | + $tableName .= "_userindex"; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | // Figure out database name. |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $offset = date('YmdHis', $offset); |
350 | 350 | $datesConditions .= " AND $tableAlias{$field} <= '$offset'"; |
351 | 351 | } elseif (is_int($end)) { |
352 | - $end = date('Ymd', $end) . '235959'; |
|
352 | + $end = date('Ymd', $end).'235959'; |
|
353 | 353 | $datesConditions .= " AND $tableAlias{$field} <= '$end'"; |
354 | 354 | } |
355 | 355 |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | throw new XtoolsHttpException( |
296 | 296 | $this->i18n->msg('not-opted-in', [ |
297 | 297 | $this->getOptedInPage()->getTitle(), |
298 | - $this->i18n->msg('not-opted-in-link') . |
|
298 | + $this->i18n->msg('not-opted-in-link'). |
|
299 | 299 | ' <https://www.mediawiki.org/wiki/Special:MyLanguage/XTools/Edit_Counter#restricted_stats>', |
300 | 300 | $this->i18n->msg('not-opted-in-login'), |
301 | 301 | ]), |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | } |
571 | 571 | |
572 | 572 | throw new XtoolsHttpException( |
573 | - $this->i18n->msg('too-many-edits', [ $user->maxEdits() ]), |
|
573 | + $this->i18n->msg('too-many-edits', [$user->maxEdits()]), |
|
574 | 574 | $this->generateUrl($this->tooHighEditCountRoute(), $this->params), |
575 | 575 | $originalParams, |
576 | 576 | $this->isApi, |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | $params = $this->convertLegacyParams($params); |
715 | 715 | |
716 | 716 | // Remove blank values. |
717 | - return array_filter($params, function ($param) { |
|
717 | + return array_filter($params, function($param) { |
|
718 | 718 | // 'namespace' or 'username' could be '0'. |
719 | 719 | return null !== $param && '' !== $param; |
720 | 720 | }); |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | // Show warnings that the date range was truncated. |
773 | 773 | $this->addFlashMessage('warning', 'date-range-too-wide', [$this->maxDays()]); |
774 | 774 | |
775 | - $startTime = strtotime('-' . $this->maxDays() . ' days', $endTime); |
|
775 | + $startTime = strtotime('-'.$this->maxDays().' days', $endTime); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | return [$startTime, $endTime]; |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | } |
945 | 945 | |
946 | 946 | $elapsedTime = round( |
947 | - microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], |
|
947 | + microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'], |
|
948 | 948 | 3 |
949 | 949 | ); |
950 | 950 | return array_merge($params, ['elapsed_time' => $elapsedTime]); |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | public function addFullPageTitlesAndContinue(string $key, array $out, array $data): array |
975 | 975 | { |
976 | 976 | // Add full_page_title (in addition to the existing page_title and namespace keys). |
977 | - $out[$key] = array_map(function ($rev) { |
|
977 | + $out[$key] = array_map(function($rev) { |
|
978 | 978 | return array_merge([ |
979 | 979 | 'full_page_title' => $this->getPageFromNsAndTitle( |
980 | 980 | (int)$rev['namespace'], |
@@ -335,7 +335,7 @@ |
||
335 | 335 | 'total_editcount' => $this->autoEdits->getEditCount(), |
336 | 336 | 'automated_editcount' => $this->autoEdits->getAutomatedCount(), |
337 | 337 | ]; |
338 | - $ret['nonautomated_editcount'] = $ret['total_editcount'] - $ret['automated_editcount']; |
|
338 | + $ret['nonautomated_editcount'] = $ret['total_editcount']-$ret['automated_editcount']; |
|
339 | 339 | |
340 | 340 | if ($this->getBoolVal('tools')) { |
341 | 341 | $tools = $this->autoEdits->getToolCounts(); |
@@ -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 | |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | ])->fetchAllAssociative(); |
162 | 162 | |
163 | 163 | $logCounts = array_combine( |
164 | - array_map(function ($e) { |
|
164 | + array_map(function($e) { |
|
165 | 165 | return $e['source']; |
166 | 166 | }, $results), |
167 | - array_map(function ($e) { |
|
167 | + array_map(function($e) { |
|
168 | 168 | return (int)$e['value']; |
169 | 169 | }, $results) |
170 | 170 | ); |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | $counts = array_combine( |
247 | - array_map(function ($e) { |
|
247 | + array_map(function($e) { |
|
248 | 248 | return $e['key']; |
249 | 249 | }, $results), |
250 | - array_map(function ($e) { |
|
250 | + array_map(function($e) { |
|
251 | 251 | return (int)$e['val']; |
252 | 252 | }, $results) |
253 | 253 | ); |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | |
430 | 430 | $results = $this->executeProjectsQuery($project, $sql, $params)->fetchAll(); |
431 | 431 | |
432 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
432 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
433 | 433 | return $e['namespace']; |
434 | - }, $results), array_map(function ($e) { |
|
434 | + }, $results), array_map(function($e) { |
|
435 | 435 | return (int)$e['total']; |
436 | 436 | }, $results)); |
437 | 437 |
@@ -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 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $hasPageAssessments = $this->isWMF && $project->hasPageAssessments($namespace); |
115 | 115 | $paTable = $project->getTableName('page_assessments'); |
116 | 116 | $paSelect = $hasPageAssessments |
117 | - ? ", ( |
|
117 | + ? ", ( |
|
118 | 118 | SELECT pa_class |
119 | 119 | FROM $paTable |
120 | 120 | WHERE pa_page_id = page_id |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $hasPageAssessments = $this->isWMF && $project->hasPageAssessments(); |
229 | 229 | $pageAssessmentsTable = $this->getTableName($project->getDatabaseName(), 'page_assessments'); |
230 | 230 | $paSelect = $hasPageAssessments |
231 | - ? ", ( |
|
231 | + ? ", ( |
|
232 | 232 | SELECT pa_class |
233 | 233 | FROM $pageAssessmentsTable |
234 | 234 | WHERE pa_page_id = e.page_id |
@@ -146,7 +146,7 @@ |
||
146 | 146 | $actionsRequested = is_array($actionsQuery) ? $actionsQuery : array_filter(explode('|', $actionsQuery)); |
147 | 147 | |
148 | 148 | // Filter out any invalid action names. |
149 | - $actions = array_filter($actionsRequested, function ($action) use ($group) { |
|
149 | + $actions = array_filter($actionsRequested, function($action) use ($group) { |
|
150 | 150 | return in_array($action, $this->getActionNames($group)); |
151 | 151 | }); |
152 | 152 |
@@ -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 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | SUM(IF(type = 'arc', 1, 0)) AS `deleted`, |
62 | 62 | SUM($summation) AS `redirects`, |
63 | 63 | SUM(rev_length) AS `total_length` |
64 | - FROM (" . |
|
64 | + FROM (". |
|
65 | 65 | $this->getPagesCreatedInnerSql($project, $conditions, $deleted, $start, $end, false, true)." |
66 | 66 | ) a ". |
67 | - $wasRedirect . |
|
67 | + $wasRedirect. |
|
68 | 68 | "GROUP BY `namespace`"; |
69 | 69 | |
70 | 70 | $result = $this->executeQuery($sql, $project, $user, $namespace) |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $sql = "SELECT * FROM (". |
131 | 131 | $this->getPagesCreatedInnerSql($project, $conditions, $deleted, $start, $end, $offset)." |
132 | 132 | ) a ". |
133 | - $wasRedirect . |
|
133 | + $wasRedirect. |
|
134 | 134 | "ORDER BY `timestamp` DESC |
135 | 135 | ".(!empty($limit) ? "LIMIT $limit" : ''); |
136 | 136 |
@@ -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 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function getUrl(bool $withTrailingSlash = true): string |
157 | 157 | { |
158 | - return rtrim($this->getBasicInfo()['url'], '/') . ($withTrailingSlash ? '/' : ''); |
|
158 | + return rtrim($this->getBasicInfo()['url'], '/').($withTrailingSlash ? '/' : ''); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if ($page instanceof Page) { |
172 | 172 | $page = $page->getTitle($useUnnormalizedPageTitle); |
173 | 173 | } |
174 | - return str_replace('$1', $page, $this->getUrl(false) . $this->getArticlePath()); |
|
174 | + return str_replace('$1', $page, $this->getUrl(false).$this->getArticlePath()); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | public function getScript(): string |
208 | 208 | { |
209 | 209 | $metadata = $this->getMetadata(); |
210 | - return $metadata['general']['script'] ?? $this->getScriptPath() . '/index.php'; |
|
210 | + return $metadata['general']['script'] ?? $this->getScriptPath().'/index.php'; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function getApiUrl(): string |
218 | 218 | { |
219 | - return rtrim($this->getUrl(), '/') . $this->getRepository()->getApiPath(); |
|
219 | + return rtrim($this->getUrl(), '/').$this->getRepository()->getApiPath(); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function userOptInPage(User $user): string |
293 | 293 | { |
294 | - return 'User:' . $user->getUsername() . '/EditCounterOptIn.js'; |
|
294 | + return 'User:'.$user->getUsername().'/EditCounterOptIn.js'; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | // 4. Lastly, see if they've opted in globally on the default project or Meta. |
328 | - $globalPageName = $user->getUsername() . '/EditCounterGlobalOptIn.js'; |
|
328 | + $globalPageName = $user->getUsername().'/EditCounterGlobalOptIn.js'; |
|
329 | 329 | $globalProject = $this->getRepository()->getGlobalProject(); |
330 | 330 | $globalExists = $globalProject->getRepository() |
331 | 331 | ->pageHasContent($globalProject, $userNsId, $globalPageName); |