@@ -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 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | { |
164 | 164 | $firstDateTime = $this->topEdits[0]->getTimestamp(); |
165 | 165 | $lastDateTime = end($this->topEdits)->getTimestamp(); |
166 | - $secs = $firstDateTime->getTimestamp() - $lastDateTime->getTimestamp(); |
|
166 | + $secs = $firstDateTime->getTimestamp()-$lastDateTime->getTimestamp(); |
|
167 | 167 | $days = $secs / (60 * 60 * 24); |
168 | 168 | return $days / count($this->topEdits); |
169 | 169 | } |
@@ -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'], |
@@ -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 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | // Filter out unblocks unless requested. |
162 | 162 | if ($blocksOnly) { |
163 | - $blocks = array_filter($blocks, function ($block) { |
|
163 | + $blocks = array_filter($blocks, function($block) { |
|
164 | 164 | return 'block' === $block['log_action']; |
165 | 165 | }); |
166 | 166 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function countAllRevisions(): int |
196 | 196 | { |
197 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
197 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function countAllPagesEdited(): int |
235 | 235 | { |
236 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
236 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function countPagesCreated(): int |
245 | 245 | { |
246 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
246 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | } elseif ('unblock' === $block['log_action']) { |
373 | 373 | // The last block was lifted. So the duration will be the time from when the |
374 | 374 | // last block was set to the time of the unblock. |
375 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
375 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
376 | 376 | if ($timeSinceLastBlock > $this->longestBlockSeconds) { |
377 | 377 | $this->longestBlockSeconds = $timeSinceLastBlock; |
378 | 378 | |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | // The last block was modified. So we will adjust $lastBlock to include |
384 | 384 | // the difference of the duration of the new reblock, and time since the last block. |
385 | 385 | // $lastBlock is left unchanged if its duration was indefinite. |
386 | - $timeSinceLastBlock = $timestamp - $lastBlock[0]; |
|
387 | - $lastBlock[1] = $timeSinceLastBlock + $duration; |
|
386 | + $timeSinceLastBlock = $timestamp-$lastBlock[0]; |
|
387 | + $lastBlock[1] = $timeSinceLastBlock+$duration; |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | // Test if the last block is still active, and if so use the expiry as the duration. |
397 | - $lastBlockExpiry = $lastBlock[0] + $lastBlock[1]; |
|
397 | + $lastBlockExpiry = $lastBlock[0]+$lastBlock[1]; |
|
398 | 398 | if ($lastBlockExpiry > time() && $lastBlockExpiry > $this->longestBlockSeconds) { |
399 | 399 | $this->longestBlockSeconds = $lastBlock[1]; |
400 | 400 | // Otherwise, test if the duration of the last block is now the longest overall. |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | // If invalid, $duration is left as null. |
439 | 439 | if (strtotime($durationStr)) { |
440 | 440 | $expiry = strtotime($durationStr, $timestamp); |
441 | - $duration = $expiry - $timestamp; |
|
441 | + $duration = $expiry-$timestamp; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | return [$timestamp, $duration]; |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | $import = $logCounts['import-import'] ?? 0; |
526 | 526 | $interwiki = $logCounts['import-interwiki'] ?? 0; |
527 | 527 | $upload = $logCounts['import-upload'] ?? 0; |
528 | - return $import + $interwiki + $upload; |
|
528 | + return $import+$interwiki+$upload; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $logCounts = $this->getLogCounts(); |
548 | 548 | $new = $logCounts['contentmodel-new'] ?? 0; |
549 | 549 | $modified = $logCounts['contentmodel-change'] ?? 0; |
550 | - return $new + $modified; |
|
550 | + return $new+$modified; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -676,9 +676,9 @@ discard block |
||
676 | 676 | public function approvals(): int |
677 | 677 | { |
678 | 678 | $logCounts = $this->getLogCounts(); |
679 | - return (!empty($logCounts['review-approve']) ? $logCounts['review-approve'] : 0) + |
|
680 | - (!empty($logCounts['review-approve2']) ? $logCounts['review-approve2'] : 0) + |
|
681 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
679 | + return (!empty($logCounts['review-approve']) ? $logCounts['review-approve'] : 0)+ |
|
680 | + (!empty($logCounts['review-approve2']) ? $logCounts['review-approve2'] : 0)+ |
|
681 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
682 | 682 | (!empty($logCounts['review-approve2-i']) ? $logCounts['review-approve2-i'] : 0); |
683 | 683 | } |
684 | 684 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | $logCounts = $this->getLogCounts(); |
702 | 702 | $create2 = $logCounts['newusers-create2'] ?: 0; |
703 | 703 | $byemail = $logCounts['newusers-byemail'] ?: 0; |
704 | - return $create2 + $byemail; |
|
704 | + return $create2+$byemail; |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | $totals = $this->repository->getMonthCounts($this->project, $this->user); |
805 | 805 | $out = [ |
806 | - 'yearLabels' => [], // labels for years |
|
806 | + 'yearLabels' => [], // labels for years |
|
807 | 807 | 'monthLabels' => [], // labels for months |
808 | 808 | 'totals' => [], // actual totals, grouped by namespace, year and then month |
809 | 809 | ]; |
@@ -1022,7 +1022,7 @@ discard block |
||
1022 | 1022 | public function countSmallEdits(): int |
1023 | 1023 | { |
1024 | 1024 | $editSizeData = $this->getEditSizeData(); |
1025 | - return isset($editSizeData['small_edits']) ? (int) $editSizeData['small_edits'] : 0; |
|
1025 | + return isset($editSizeData['small_edits']) ? (int)$editSizeData['small_edits'] : 0; |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | /** |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | public function countLargeEdits(): int |
1033 | 1033 | { |
1034 | 1034 | $editSizeData = $this->getEditSizeData(); |
1035 | - return isset($editSizeData['large_edits']) ? (int) $editSizeData['large_edits'] : 0; |
|
1035 | + return isset($editSizeData['large_edits']) ? (int)$editSizeData['large_edits'] : 0; |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -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 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | $numResults = count($this->getResults()[$this->getNamespace()]); |
137 | - $timestamp = new DateTime($this->getResults()[$this->getNamespace()][$numResults - 1]['timestamp']); |
|
137 | + $timestamp = new DateTime($this->getResults()[$this->getNamespace()][$numResults-1]['timestamp']); |
|
138 | 138 | return $timestamp->format('Y-m-d\TH:i:s\Z'); |
139 | 139 | } |
140 | 140 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $summaryColumns[] = 'average-page-size'; |
343 | 343 | |
344 | 344 | // Re-sort based on $order |
345 | - return array_values(array_filter($order, static function ($column) use ($summaryColumns) { |
|
345 | + return array_values(array_filter($order, static function($column) use ($summaryColumns) { |
|
346 | 346 | return in_array($column, $summaryColumns); |
347 | 347 | })); |
348 | 348 | } |
@@ -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 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | [$bytes, $chars, $words] = $this->countCharsAndWords($crawler); |
181 | 181 | |
182 | 182 | $refContent = []; |
183 | - $refs->each(function ($ref) use (&$refContent): void { |
|
183 | + $refs->each(function($ref) use (&$refContent): void { |
|
184 | 184 | $refContent[] = $ref->text(); |
185 | 185 | }); |
186 | 186 | $uniqueRefs = count(array_unique($refContent)); |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | '[typeof~="mw:Extension/templatestyles"]', |
216 | 216 | '[typeof~="mw:Extension/math"]', |
217 | 217 | '[typeof~="mw:Extension/ref"]', |
218 | - ]))->each(function (Crawler $subCrawler) { |
|
218 | + ]))->each(function(Crawler $subCrawler) { |
|
219 | 219 | foreach ($subCrawler as $subNode) { |
220 | 220 | $subNode->parentNode->removeChild($subNode); |
221 | 221 | } |
222 | 222 | }); |
223 | 223 | |
224 | - $paragraphs->each(function ($node) use (&$totalBytes, &$totalChars, &$totalWords): void { |
|
224 | + $paragraphs->each(function($node) use (&$totalBytes, &$totalChars, &$totalWords): void { |
|
225 | 225 | /** @var Crawler $node */ |
226 | 226 | $text = $node->text(); |
227 | 227 | $totalBytes += strlen($text); |
@@ -306,24 +306,24 @@ discard block |
||
306 | 306 | if ($info) { |
307 | 307 | $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']); |
308 | 308 | $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']); |
309 | - $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp(); |
|
309 | + $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp(); |
|
310 | 310 | |
311 | 311 | $assessment = $page->getProject() |
312 | 312 | ->getPageAssessments() |
313 | 313 | ->getAssessment($page); |
314 | 314 | |
315 | 315 | $data = array_merge($data, [ |
316 | - 'revisions' => (int) $info['num_edits'], |
|
317 | - 'editors' => (int) $info['num_editors'], |
|
318 | - 'ip_edits' => (int) $info['ip_edits'], |
|
319 | - 'minor_edits' => (int) $info['minor_edits'], |
|
316 | + 'revisions' => (int)$info['num_edits'], |
|
317 | + 'editors' => (int)$info['num_editors'], |
|
318 | + 'ip_edits' => (int)$info['ip_edits'], |
|
319 | + 'minor_edits' => (int)$info['minor_edits'], |
|
320 | 320 | 'creator' => $info['creator'], |
321 | - 'creator_editcount' => null === $info['creator_editcount'] ? null : (int) $info['creator_editcount'], |
|
321 | + 'creator_editcount' => null === $info['creator_editcount'] ? null : (int)$info['creator_editcount'], |
|
322 | 322 | 'created_at' => $creationDateTime, |
323 | 323 | 'created_rev_id' => $info['created_rev_id'], |
324 | 324 | 'modified_at' => $modifiedDateTime, |
325 | 325 | 'secs_since_last_edit' => $secsSinceLastEdit, |
326 | - 'modified_rev_id' => (int) $info['modified_rev_id'], |
|
326 | + 'modified_rev_id' => (int)$info['modified_rev_id'], |
|
327 | 327 | 'assessment' => $assessment, |
328 | 328 | ]); |
329 | 329 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | // Sort by edit count. |
476 | - uasort($this->bots, function ($a, $b) { |
|
477 | - return $b['count'] - $a['count']; |
|
476 | + uasort($this->bots, function($a, $b) { |
|
477 | + return $b['count']-$a['count']; |
|
478 | 478 | }); |
479 | 479 | |
480 | 480 | return $this->bots; |
@@ -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 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | User $user, |
113 | 113 | array $revs |
114 | 114 | ): array { |
115 | - return array_map(function ($rev) use ($pageRepo, $editRepo, $userRepo, $project, $user) { |
|
115 | + return array_map(function($rev) use ($pageRepo, $editRepo, $userRepo, $project, $user) { |
|
116 | 116 | /** Page object to be passed to the Edit constructor. */ |
117 | 117 | $page = Page::newFromRow($pageRepo, $project, $rev); |
118 | 118 | $rev['user'] = $user; |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | // Must have underscores for the link to properly go to the section. |
359 | 359 | $sectionTitleLink = htmlspecialchars(str_replace(' ', '_', $sectionTitle)); |
360 | 360 | |
361 | - $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>" . |
|
362 | - "<em class='text-muted'>" . htmlspecialchars($sectionTitle) . ":</em> "; |
|
361 | + $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>". |
|
362 | + "<em class='text-muted'>".htmlspecialchars($sectionTitle).":</em> "; |
|
363 | 363 | $summary = str_replace($sectionMatch[0][0], $sectionWikitext, $summary); |
364 | 364 | } |
365 | 365 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | public function getDiffUrl(): string |
408 | 408 | { |
409 | - return rtrim($this->getProject()->getUrlForPage('Special:Diff/' . $this->id), '/'); |
|
409 | + return rtrim($this->getProject()->getUrlForPage('Special:Diff/'.$this->id), '/'); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | /** |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | */ |
416 | 416 | public function getPermaUrl(): string |
417 | 417 | { |
418 | - return rtrim($this->getProject()->getUrlForPage('Special:PermaLink/' . $this->id), '/'); |
|
418 | + return rtrim($this->getProject()->getUrlForPage('Special:PermaLink/'.$this->id), '/'); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -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 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ); |
178 | 178 | |
179 | 179 | if ($raw) { |
180 | - return array_map(function (Edit $edit) { |
|
180 | + return array_map(function(Edit $edit) { |
|
181 | 181 | return $edit->getForJson(); |
182 | 182 | }, $this->nonAutomatedEdits); |
183 | 183 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | ); |
218 | 218 | |
219 | 219 | if ($forJson) { |
220 | - return array_map(function (Edit $edit) { |
|
220 | + return array_map(function(Edit $edit) { |
|
221 | 221 | return $edit->getForJson(); |
222 | 222 | }, $this->automatedEdits); |
223 | 223 | } |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | public function getToolsTotal(): int |
270 | 270 | { |
271 | 271 | if (!isset($this->toolsTotal)) { |
272 | - $this->toolsTotal = array_reduce($this->getToolCounts(), function ($a, $b) { |
|
273 | - return $a + $b['count']; |
|
272 | + $this->toolsTotal = array_reduce($this->getToolCounts(), function($a, $b) { |
|
273 | + return $a+$b['count']; |
|
274 | 274 | }); |
275 | 275 | } |
276 | 276 |
@@ -361,7 +361,7 @@ |
||
361 | 361 | $responseCode = Response::HTTP_OK; |
362 | 362 | $this->recordApiUsage('page/prose'); |
363 | 363 | $this->setupPageInfo($pageInfoRepo, $autoEditsHelper); |
364 | - $this->addFlash('info', 'The algorithm used by this API has recently changed. ' . |
|
364 | + $this->addFlash('info', 'The algorithm used by this API has recently changed. '. |
|
365 | 365 | 'See https://www.mediawiki.org/wiki/XTools/Page_History#Prose for details.'); |
366 | 366 | $ret = $this->pageInfo->getProseStats(); |
367 | 367 | if (null === $ret) { |
@@ -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\Controller; |
6 | 6 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $this->project = $defaultProject; |
231 | 231 | |
232 | 232 | $results = $globalContribs->globalEdits(); |
233 | - $results = array_map(function (Edit $edit) { |
|
233 | + $results = array_map(function(Edit $edit) { |
|
234 | 234 | return $edit->getForJson(true); |
235 | 235 | }, array_values($results)); |
236 | 236 | $results = $this->addFullPageTitlesAndContinue('globalcontribs', [], $results); |