@@ -3,7 +3,7 @@ |
||
| 3 | 3 | * This file contains only the AdminStatsRepository class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace App\Repository; |
| 9 | 9 | |
@@ -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 App\Repository; |
| 9 | 9 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if ('all' !== $namespace) { |
| 56 | 56 | // Limit by namespace. |
| 57 | - return array_filter($this->aeTools, function (array $tool) use ($namespace) { |
|
| 57 | + return array_filter($this->aeTools, function(array $tool) use ($namespace) { |
|
| 58 | 58 | return empty($tool['namespaces']) || |
| 59 | 59 | in_array((int)$namespace, $tool['namespaces']) || |
| 60 | 60 | ( |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $tagJoin = "LEFT OUTER JOIN $tagTable ON ct_rev_id = rev_id"; |
| 151 | 151 | $condTools[] = "ct_tag_id IN ($tagIds)"; |
| 152 | 152 | } |
| 153 | - $condTool = 'AND (' . implode(' OR ', $condTools) . ')'; |
|
| 153 | + $condTool = 'AND ('.implode(' OR ', $condTools).')'; |
|
| 154 | 154 | |
| 155 | 155 | $sql = "SELECT COUNT(DISTINCT(rev_id)) |
| 156 | 156 | FROM $revisionTable |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // Sort the array by count |
| 398 | - uasort($results, function ($a, $b) { |
|
| 399 | - return $b['count'] - $a['count']; |
|
| 398 | + uasort($results, function($a, $b) { |
|
| 399 | + return $b['count']-$a['count']; |
|
| 400 | 400 | }); |
| 401 | 401 | |
| 402 | 402 | // Cache and return. |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | if (isset($values['tags'])) { |
| 588 | 588 | $tags = array_merge( |
| 589 | 589 | $tags, |
| 590 | - array_map(function ($tag) use ($conn) { |
|
| 590 | + array_map(function($tag) use ($conn) { |
|
| 591 | 591 | return $conn->quote($tag, PDO::PARAM_STR); |
| 592 | 592 | }, $values['tags']) |
| 593 | 593 | ); |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | |
| 624 | 624 | if ($tagExcludes && 1 === count($tagIds)) { |
| 625 | 625 | // Get tag IDs, filtering out those for which no ID exists (meaning there is no local tag for that tool). |
| 626 | - $excludesList = implode(',', array_filter(array_map(function ($tagName) use ($project) { |
|
| 626 | + $excludesList = implode(',', array_filter(array_map(function($tagName) use ($project) { |
|
| 627 | 627 | return $this->getTags($project)[$tagName] ?? null; |
| 628 | 628 | }, $tagExcludes))); |
| 629 | 629 | |
@@ -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 App\Repository; |
| 9 | 9 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | // $tableExtension in order to generate the new table name |
| 222 | 222 | if ($this->isLabs() && null !== $tableExtension) { |
| 223 | 223 | $mapped = true; |
| 224 | - $tableName .=('' === $tableExtension ? '' : '_'.$tableExtension); |
|
| 224 | + $tableName .= ('' === $tableExtension ? '' : '_'.$tableExtension); |
|
| 225 | 225 | } elseif ($this->container->hasParameter("app.table.$tableName")) { |
| 226 | 226 | // Use the table specified in the table mapping configuration, if present. |
| 227 | 227 | $mapped = true; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | // This is a safeguard in case table mapping isn't properly set up. |
| 234 | 234 | $isLoggingOrRevision = in_array($tableName, ['revision', 'logging', 'archive']); |
| 235 | 235 | if (!$mapped && $isLoggingOrRevision && $this->isLabs()) { |
| 236 | - $tableName .="_userindex"; |
|
| 236 | + $tableName .= "_userindex"; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Figure out database name. |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | $offset = date('YmdHis', $offset); |
| 353 | 353 | $datesConditions .= " AND {$tableAlias}{$field} <= '$offset'"; |
| 354 | 354 | } elseif (is_int($end)) { |
| 355 | - $end = date('Ymd', $end) . '235959'; |
|
| 355 | + $end = date('Ymd', $end).'235959'; |
|
| 356 | 356 | $datesConditions .= " AND {$tableAlias}{$field} <= '$end'"; |
| 357 | 357 | } |
| 358 | 358 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * This file contains only the PageRepository class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace App\Repository; |
| 9 | 9 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $wikidataId = ltrim($page->getWikidataId(), 'Q'); |
| 308 | 308 | |
| 309 | - $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . " |
|
| 309 | + $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')." |
|
| 310 | 310 | FROM wikidatawiki_p.wb_items_per_site |
| 311 | 311 | WHERE ips_item_id = :wikidataId"; |
| 312 | 312 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | 'wikidataId' => $wikidataId, |
| 315 | 315 | ])->fetchAll(); |
| 316 | 316 | |
| 317 | - return $count ? (int) $result[0]['count'] : $result; |
|
| 317 | + return $count ? (int)$result[0]['count'] : $result; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | // Transform to associative array by 'type' |
| 354 | 354 | foreach ($res as $row) { |
| 355 | - $data[$row['type'] . '_count'] = (int)$row['value']; |
|
| 355 | + $data[$row['type'].'_count'] = (int)$row['value']; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | return $data; |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | $project = $page->getProject()->getDomain(); |
| 398 | 398 | |
| 399 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . |
|
| 399 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. |
|
| 400 | 400 | "$project/all-access/user/$title/daily/$start/$end"; |
| 401 | 401 | |
| 402 | 402 | $res = $client->request('GET', $url); |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | $normalized = []; |
| 472 | 472 | if (isset($result['query']['normalized'])) { |
| 473 | 473 | array_map( |
| 474 | - function ($e) use (&$normalized): void { |
|
| 474 | + function($e) use (&$normalized): void { |
|
| 475 | 475 | $normalized[$e['to']] = $e['from']; |
| 476 | 476 | }, |
| 477 | 477 | $result['query']['normalized'] |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * This file contains only the TopEditsRepository class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace App\Repository; |
| 9 | 9 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $hasPageAssessments = $this->isLabs() && $project->hasPageAssessments() && 0 === $namespace; |
| 66 | 66 | $paTable = $project->getTableName('page_assessments'); |
| 67 | 67 | $paSelect = $hasPageAssessments |
| 68 | - ? ", ( |
|
| 68 | + ? ", ( |
|
| 69 | 69 | SELECT pa_class |
| 70 | 70 | FROM $paTable |
| 71 | 71 | WHERE pa_page_id = page_id |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $hasPageAssessments = $this->isLabs() && $project->hasPageAssessments(); |
| 180 | 180 | $pageAssessmentsTable = $this->getTableName($project->getDatabaseName(), 'page_assessments'); |
| 181 | 181 | $paSelect = $hasPageAssessments |
| 182 | - ? ", ( |
|
| 182 | + ? ", ( |
|
| 183 | 183 | SELECT pa_class |
| 184 | 184 | FROM $pageAssessmentsTable |
| 185 | 185 | WHERE pa_page_id = e.page_id |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | * This file contains only the Model class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace App\Model; |
| 9 | 9 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * This file contains only the Project class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace App\Model; |
| 9 | 9 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function getUrl(bool $withTrailingSlash = true): string |
| 152 | 152 | { |
| 153 | - return rtrim($this->getBasicInfo()['url'], '/') . ($withTrailingSlash ? '/' : ''); |
|
| 153 | + return rtrim($this->getBasicInfo()['url'], '/').($withTrailingSlash ? '/' : ''); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | public function getScript(): string |
| 187 | 187 | { |
| 188 | 188 | $metadata = $this->getMetadata(); |
| 189 | - return $metadata['general']['script'] ?? $this->getScriptPath() . '/index.php'; |
|
| 189 | + return $metadata['general']['script'] ?? $this->getScriptPath().'/index.php'; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | public function getApiUrl(): string |
| 197 | 197 | { |
| 198 | - return rtrim($this->getUrl(), '/') . $this->getRepository()->getApiPath(); |
|
| 198 | + return rtrim($this->getUrl(), '/').$this->getRepository()->getApiPath(); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | */ |
| 271 | 271 | public function userOptInPage(User $user): string |
| 272 | 272 | { |
| 273 | - return 'User:' . $user->getUsername() . '/EditCounterOptIn.js'; |
|
| 273 | + return 'User:'.$user->getUsername().'/EditCounterOptIn.js'; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // 4. Lastly, see if they've opted in globally on the default project or Meta. |
| 307 | - $globalPageName = $user->getUsername() . '/EditCounterGlobalOptIn.js'; |
|
| 307 | + $globalPageName = $user->getUsername().'/EditCounterGlobalOptIn.js'; |
|
| 308 | 308 | $globalProject = $this->getRepository()->getGlobalProject(); |
| 309 | 309 | if ($globalProject instanceof Project) { |
| 310 | 310 | $globalExists = $globalProject->getRepository() |
@@ -213,9 +213,9 @@ |
||
| 213 | 213 | // Record character count and percentage for the remaining editors. |
| 214 | 214 | if ($percentageSum < 100) { |
| 215 | 215 | $this->data['others'] = [ |
| 216 | - 'count' => $totalCount - $countSum, |
|
| 217 | - 'percentage' => round(100 - $percentageSum, 1), |
|
| 218 | - 'numEditors' => count($counts) - $numEditors, |
|
| 216 | + 'count' => $totalCount-$countSum, |
|
| 217 | + 'percentage' => round(100-$percentageSum, 1), |
|
| 218 | + 'numEditors' => count($counts)-$numEditors, |
|
| 219 | 219 | ]; |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * This file contains only the Page class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace App\Model; |
| 9 | 9 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $title = $info['title'] ?? $this->unnormalizedPageName; |
| 127 | 127 | $nsName = $this->getNamespaceName(); |
| 128 | 128 | return $nsName |
| 129 | - ? str_replace($nsName . ':', '', $title) |
|
| 129 | + ? str_replace($nsName.':', '', $title) |
|
| 130 | 130 | : $title; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | { |
| 333 | 333 | $content = $this->getRepository()->getPagesWikitext( |
| 334 | 334 | $this->getProject(), |
| 335 | - [ $this->getTitle() ] |
|
| 335 | + [$this->getTitle()] |
|
| 336 | 336 | ); |
| 337 | 337 | |
| 338 | 338 | return $content[$this->getTitle()] ?? null; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | $wikidataInfo = $this->getRepository()->getWikidataInfo($this); |
| 400 | 400 | |
| 401 | - $terms = array_map(function ($entry) { |
|
| 401 | + $terms = array_map(function($entry) { |
|
| 402 | 402 | return $entry['term']; |
| 403 | 403 | }, $wikidataInfo); |
| 404 | 404 | |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | 'prio' => 2, |
| 410 | 410 | 'name' => 'Wikidata', |
| 411 | 411 | 'notice' => "Label 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:Label'>Help:Label</a>", |
| 414 | 414 | ]; |
| 415 | 415 | } |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | 'prio' => 3, |
| 420 | 420 | 'name' => 'Wikidata', |
| 421 | 421 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
| 422 | - 'explanation' => "See: <a target='_blank' " . |
|
| 422 | + 'explanation' => "See: <a target='_blank' ". |
|
| 423 | 423 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
| 424 | 424 | ]; |
| 425 | 425 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | return 0; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - return array_sum(array_map(function ($item) { |
|
| 500 | + return array_sum(array_map(function($item) { |
|
| 501 | 501 | return (int)$item['views']; |
| 502 | 502 | }, $pageviews['items'])); |
| 503 | 503 | } |