@@ -7,7 +7,6 @@ |
||
| 7 | 7 | |
| 8 | 8 | use AppBundle\Helper\AutomatedEditsHelper; |
| 9 | 9 | use DateInterval; |
| 10 | -use DateTime; |
|
| 11 | 10 | use Mediawiki\Api\SimpleRequest; |
| 12 | 11 | |
| 13 | 12 | /** |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | public function getPairData(Project $project, User $user) |
| 28 | 28 | { |
| 29 | 29 | // Set up cache. |
| 30 | - $cacheKey = 'pairdata.' . $project->getDatabaseName() . '.' . $user->getUsername(); |
|
| 30 | + $cacheKey = 'pairdata.'.$project->getDatabaseName().'.'.$user->getUsername(); |
|
| 31 | 31 | if ($this->cache->hasItem($cacheKey)) { |
| 32 | 32 | return $this->cache->getItem($cacheKey)->get(); |
| 33 | 33 | } |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | $resultQuery->execute(); |
| 154 | 154 | $results = $resultQuery->fetchAll(); |
| 155 | 155 | $logCounts = array_combine( |
| 156 | - array_map(function ($e) { |
|
| 156 | + array_map(function($e) { |
|
| 157 | 157 | return $e['source']; |
| 158 | 158 | }, $results), |
| 159 | - array_map(function ($e) { |
|
| 159 | + array_map(function($e) { |
|
| 160 | 160 | return $e['value']; |
| 161 | 161 | }, $results) |
| 162 | 162 | ); |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | $resultQuery->bindParam(":id", $userId); |
| 379 | 379 | $resultQuery->execute(); |
| 380 | 380 | $results = $resultQuery->fetchAll(); |
| 381 | - $namespaceTotals = array_combine(array_map(function ($e) { |
|
| 381 | + $namespaceTotals = array_combine(array_map(function($e) { |
|
| 382 | 382 | return $e['page_namespace']; |
| 383 | - }, $results), array_map(function ($e) { |
|
| 383 | + }, $results), array_map(function($e) { |
|
| 384 | 384 | return $e['total']; |
| 385 | 385 | }, $results)); |
| 386 | 386 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | $queries[] = $sql; |
| 441 | 441 | } |
| 442 | - $sql = "(\n" . join("\n) UNION (\n", $queries) . ")\n"; |
|
| 442 | + $sql = "(\n".join("\n) UNION (\n", $queries).")\n"; |
|
| 443 | 443 | $resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 444 | 444 | $resultQuery->bindParam(":username", $username); |
| 445 | 445 | $resultQuery->execute(); |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
| 48 | 48 | |
| 49 | 49 | // Check that a correct namespace value was returned |
| 50 | - $response = (array) json_decode($client->getResponse()->getContent()); |
|
| 51 | - $namespaces = (array) $response['namespaces']; |
|
| 50 | + $response = (array)json_decode($client->getResponse()->getContent()); |
|
| 51 | + $namespaces = (array)$response['namespaces']; |
|
| 52 | 52 | $this->assertEquals('Utilisateur', array_values($namespaces)[2]); // User in French |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function getPairData() |
| 63 | 63 | { |
| 64 | - if (! is_array($this->pairData)) { |
|
| 64 | + if (!is_array($this->pairData)) { |
|
| 65 | 65 | $this->pairData = $this->getRepository() |
| 66 | 66 | ->getPairData($this->project, $this->user); |
| 67 | 67 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | protected function getLogCounts() |
| 76 | 76 | { |
| 77 | - if (! is_array($this->logCounts)) { |
|
| 77 | + if (!is_array($this->logCounts)) { |
|
| 78 | 78 | $this->logCounts = $this->getRepository() |
| 79 | 79 | ->getLogCounts($this->project, $this->user); |
| 80 | 80 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | public function countAllRevisions() |
| 125 | 125 | { |
| 126 | - return $this->countLiveRevisions() + $this->countDeletedRevisions(); |
|
| 126 | + return $this->countLiveRevisions()+$this->countDeletedRevisions(); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function countRevisionsWithoutComments() |
| 144 | 144 | { |
| 145 | - return $this->countAllRevisions() - $this->countRevisionsWithComments(); |
|
| 145 | + return $this->countAllRevisions()-$this->countRevisionsWithComments(); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | public function countAllPagesEdited() |
| 214 | 214 | { |
| 215 | - return $this->countLivePagesEdited() + $this->countDeletedPagesEdited(); |
|
| 215 | + return $this->countLivePagesEdited()+$this->countDeletedPagesEdited(); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | public function countPagesCreated() |
| 224 | 224 | { |
| 225 | - return $this->countCreatedPagesLive() + $this->countPagesCreatedDeleted(); |
|
| 225 | + return $this->countCreatedPagesLive()+$this->countPagesCreatedDeleted(); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | $logCounts = $this->getLogCounts(); |
| 275 | 275 | $block = isset($logCounts['block-block']) ? (int)$logCounts['block-block'] : 0; |
| 276 | 276 | $reBlock = isset($logCounts['block-reblock']) ? (int)$logCounts['block-reblock'] : 0; |
| 277 | - return $block + $reBlock; |
|
| 277 | + return $block+$reBlock; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | // Try block just in case there are older, unpredictable formats |
| 331 | 331 | try { |
| 332 | 332 | $expiry = strtotime($durationStr, $timestamp); |
| 333 | - $duration = ($expiry - $timestamp) / (60 * 60 * 24); |
|
| 333 | + $duration = ($expiry-$timestamp) / (60 * 60 * 24); |
|
| 334 | 334 | |
| 335 | 335 | if (!$duration || $duration > $this->longestBlockDays) { |
| 336 | 336 | $this->longestBlockDays = $duration; |
@@ -418,7 +418,7 @@ discard block |
||
| 418 | 418 | $import = isset($logCounts['import-import']) ? (int)$logCounts['import-import'] : 0; |
| 419 | 419 | $interwiki = isset($logCounts['import-interwiki']) ? (int)$logCounts['import-interwiki'] : 0; |
| 420 | 420 | $upload = isset($logCounts['import-upload']) ? (int)$logCounts['import-upload'] : 0; |
| 421 | - return $import + $interwiki + $upload; |
|
| 421 | + return $import+$interwiki+$upload; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | /** |
@@ -551,9 +551,9 @@ discard block |
||
| 551 | 551 | public function approvals() |
| 552 | 552 | { |
| 553 | 553 | $logCounts = $this->getLogCounts(); |
| 554 | - $total = $logCounts['review-approve'] + |
|
| 555 | - (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0) + |
|
| 556 | - (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0) + |
|
| 554 | + $total = $logCounts['review-approve']+ |
|
| 555 | + (!empty($logCounts['review-approve-a']) ? $logCounts['review-approve-a'] : 0)+ |
|
| 556 | + (!empty($logCounts['review-approve-i']) ? $logCounts['review-approve-i'] : 0)+ |
|
| 557 | 557 | (!empty($logCounts['review-approve-ia']) ? $logCounts['review-approve-ia'] : 0); |
| 558 | 558 | return $total; |
| 559 | 559 | } |
@@ -635,14 +635,14 @@ discard block |
||
| 635 | 635 | if (!isset($out['totals'][$ns])) { |
| 636 | 636 | $out['totals'][$ns] = []; |
| 637 | 637 | } |
| 638 | - $out['totals'][$ns][$total['year'] . $total['month']] = $total['count']; |
|
| 638 | + $out['totals'][$ns][$total['year'].$total['month']] = $total['count']; |
|
| 639 | 639 | } |
| 640 | 640 | // Fill in the blanks (where no edits were made in a given month for a namespace). |
| 641 | 641 | for ($y = $out['min_year']; $y <= $out['max_year']; $y++) { |
| 642 | 642 | for ($m = 1; $m <= 12; $m++) { |
| 643 | 643 | foreach ($out['totals'] as $nsId => &$total) { |
| 644 | - if (!isset($total[$y . $m])) { |
|
| 645 | - $total[$y . $m] = 0; |
|
| 644 | + if (!isset($total[$y.$m])) { |
|
| 645 | + $total[$y.$m] = 0; |
|
| 646 | 646 | } |
| 647 | 647 | } |
| 648 | 648 | } |
@@ -704,8 +704,8 @@ discard block |
||
| 704 | 704 | ->globalEditCounts($this->user, $this->project); |
| 705 | 705 | if ($sorted) { |
| 706 | 706 | // Sort. |
| 707 | - uasort($this->globalEditCounts, function ($a, $b) { |
|
| 708 | - return $b['total'] - $a['total']; |
|
| 707 | + uasort($this->globalEditCounts, function($a, $b) { |
|
| 708 | + return $b['total']-$a['total']; |
|
| 709 | 709 | }); |
| 710 | 710 | } |
| 711 | 711 | } |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | $nsName = $project->getNamespaces()[$revision['page_namespace']]; |
| 744 | 744 | } |
| 745 | 745 | $page = $project->getRepository() |
| 746 | - ->getPage($project, $nsName . ':' . $revision['page_title']); |
|
| 746 | + ->getPage($project, $nsName.':'.$revision['page_title']); |
|
| 747 | 747 | $edit = new Edit($page, $revision); |
| 748 | 748 | $globalEdits[$edit->getTimestamp()->getTimestamp().'-'.$edit->getId()] = $edit; |
| 749 | 749 | } |