@@ -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 AppBundle\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 ArticleInfoRepository class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace AppBundle\Repository; |
| 9 | 9 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $sql = "SELECT log_action, log_type, log_timestamp AS 'timestamp' |
| 86 | 86 | FROM $loggingTable |
| 87 | - WHERE log_namespace = '" . $page->getNamespace() . "' |
|
| 87 | + WHERE log_namespace = '".$page->getNamespace()."' |
|
| 88 | 88 | AND log_title = :title AND log_timestamp > 1 $datesConditions |
| 89 | 89 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
| 90 | 90 | $title = str_replace(' ', '_', $page->getTitle()); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $time2 = time(); |
| 266 | 266 | |
| 267 | 267 | // If it took over 5 seconds, cache the result for 20 minutes. |
| 268 | - if ($time2 - $time1 > 5) { |
|
| 268 | + if ($time2-$time1 > 5) { |
|
| 269 | 269 | $this->setCache($cacheKey, $result, 'PT20M'); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | |
| 4 | 4 | namespace AppBundle\Model; |
| 5 | 5 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $refs = $crawler->filter('#mw-content-text .reference'); |
| 168 | 168 | $refContent = []; |
| 169 | - $refs->each(function ($ref) use (&$refContent): void { |
|
| 169 | + $refs->each(function($ref) use (&$refContent): void { |
|
| 170 | 170 | $refContent[] = $ref->text(); |
| 171 | 171 | }); |
| 172 | 172 | $uniqueRefs = count(array_unique($refContent)); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $totalChars = 0; |
| 195 | 195 | $totalWords = 0; |
| 196 | 196 | $paragraphs = $crawler->filter($selector); |
| 197 | - $paragraphs->each(function ($node) use (&$totalChars, &$totalWords): void { |
|
| 197 | + $paragraphs->each(function($node) use (&$totalChars, &$totalWords): void { |
|
| 198 | 198 | $text = preg_replace('/\[\d+]/', '', trim($node->text())); |
| 199 | 199 | $totalChars += strlen($text); |
| 200 | 200 | $totalWords += count(explode(' ', $text)); |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $data = [ |
| 258 | 258 | 'project' => $project->getDomain(), |
| 259 | 259 | 'page' => $page->getTitle(), |
| 260 | - 'watchers' => (int) $page->getWatchers(), |
|
| 260 | + 'watchers' => (int)$page->getWatchers(), |
|
| 261 | 261 | 'pageviews' => $page->getLastPageviews($pageviewsOffset), |
| 262 | 262 | 'pageviews_offset' => $pageviewsOffset, |
| 263 | 263 | ]; |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | if (false !== $info) { |
| 283 | 283 | $creationDateTime = DateTime::createFromFormat('YmdHis', $info['created_at']); |
| 284 | 284 | $modifiedDateTime = DateTime::createFromFormat('YmdHis', $info['modified_at']); |
| 285 | - $secsSinceLastEdit = (new DateTime)->getTimestamp() - $modifiedDateTime->getTimestamp(); |
|
| 285 | + $secsSinceLastEdit = (new DateTime)->getTimestamp()-$modifiedDateTime->getTimestamp(); |
|
| 286 | 286 | |
| 287 | 287 | // Some wikis (such foundation.wikimedia.org) may be missing the creation date. |
| 288 | 288 | $creationDateTime = false === $creationDateTime |
@@ -294,16 +294,16 @@ discard block |
||
| 294 | 294 | ->getAssessment($page); |
| 295 | 295 | |
| 296 | 296 | $data = array_merge($data, [ |
| 297 | - 'revisions' => (int) $info['num_edits'], |
|
| 298 | - 'editors' => (int) $info['num_editors'], |
|
| 299 | - 'minor_edits' => (int) $info['minor_edits'], |
|
| 297 | + 'revisions' => (int)$info['num_edits'], |
|
| 298 | + 'editors' => (int)$info['num_editors'], |
|
| 299 | + 'minor_edits' => (int)$info['minor_edits'], |
|
| 300 | 300 | 'author' => $info['author'], |
| 301 | - 'author_editcount' => (int) $info['author_editcount'], |
|
| 301 | + 'author_editcount' => (int)$info['author_editcount'], |
|
| 302 | 302 | 'created_at' => $creationDateTime, |
| 303 | 303 | 'created_rev_id' => $info['created_rev_id'], |
| 304 | 304 | 'modified_at' => $modifiedDateTime->format('Y-m-d H:i'), |
| 305 | 305 | 'secs_since_last_edit' => $secsSinceLastEdit, |
| 306 | - 'last_edit_id' => (int) $info['modified_rev_id'], |
|
| 306 | + 'last_edit_id' => (int)$info['modified_rev_id'], |
|
| 307 | 307 | 'assessment' => $assessment, |
| 308 | 308 | ]); |
| 309 | 309 | } |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // Sort by edit count. |
| 456 | - uasort($this->bots, function ($a, $b) { |
|
| 457 | - return $b['count'] - $a['count']; |
|
| 456 | + uasort($this->bots, function($a, $b) { |
|
| 457 | + return $b['count']-$a['count']; |
|
| 458 | 458 | }); |
| 459 | 459 | |
| 460 | 460 | return $this->bots; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * This file contains only the ArticleInfo class. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -declare(strict_types = 1); |
|
| 6 | +declare(strict_types=1); |
|
| 7 | 7 | |
| 8 | 8 | namespace AppBundle\Model; |
| 9 | 9 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | public function getMaxRevisions(): int |
| 174 | 174 | { |
| 175 | 175 | if (!isset($this->maxRevisions)) { |
| 176 | - $this->maxRevisions = (int) $this->container->getParameter('app.max_page_revisions'); |
|
| 176 | + $this->maxRevisions = (int)$this->container->getParameter('app.max_page_revisions'); |
|
| 177 | 177 | } |
| 178 | 178 | return $this->maxRevisions; |
| 179 | 179 | } |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | $this->yearMonthCounts[$editYear]['all']++; |
| 793 | 793 | $this->yearMonthCounts[$editYear]['months'][$editMonth]['all']++; |
| 794 | 794 | // This will ultimately be the size of the page by the end of the year |
| 795 | - $this->yearMonthCounts[$editYear]['size'] = (int) $edit->getLength(); |
|
| 795 | + $this->yearMonthCounts[$editYear]['size'] = (int)$edit->getLength(); |
|
| 796 | 796 | |
| 797 | 797 | // Keep track of which month had the most edits |
| 798 | 798 | $editsThisMonth = $this->yearMonthCounts[$editYear]['months'][$editMonth]['all']; |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | |
| 1004 | 1004 | if ($info['all'] > 1) { |
| 1005 | 1005 | // Number of seconds/days between first and last edit. |
| 1006 | - $secs = $info['last']->getTimestamp() - $info['first']->getTimestamp(); |
|
| 1006 | + $secs = $info['last']->getTimestamp()-$info['first']->getTimestamp(); |
|
| 1007 | 1007 | $days = $secs / (60 * 60 * 24); |
| 1008 | 1008 | |
| 1009 | 1009 | // Average time between edits (in days). |
@@ -1012,7 +1012,7 @@ discard block |
||
| 1012 | 1012 | } |
| 1013 | 1013 | |
| 1014 | 1014 | // Loop through again and add percentages. |
| 1015 | - $this->topTenEditorsByEdits = array_map(function ($editor) use ($topTenCount) { |
|
| 1015 | + $this->topTenEditorsByEdits = array_map(function($editor) use ($topTenCount) { |
|
| 1016 | 1016 | $editor['percentage'] = 100 * ($editor['value'] / $topTenCount); |
| 1017 | 1017 | return $editor; |
| 1018 | 1018 | }, $topTenEditorsByEdits); |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | { |
| 1031 | 1031 | // First sort editors array by the amount of text they added. |
| 1032 | 1032 | $topTenEditorsByAdded = $this->editors; |
| 1033 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
| 1033 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
| 1034 | 1034 | if ($a['added'] === $b['added']) { |
| 1035 | 1035 | return 0; |
| 1036 | 1036 | } |
@@ -1041,12 +1041,12 @@ discard block |
||
| 1041 | 1041 | $topTenEditorsByAdded = array_keys(array_slice($topTenEditorsByAdded, 0, 10, true)); |
| 1042 | 1042 | |
| 1043 | 1043 | // Get the sum of added text so that we can add in percentages. |
| 1044 | - $topTenTotalAdded = array_sum(array_map(function ($editor) { |
|
| 1044 | + $topTenTotalAdded = array_sum(array_map(function($editor) { |
|
| 1045 | 1045 | return $this->editors[$editor]['added']; |
| 1046 | 1046 | }, $topTenEditorsByAdded)); |
| 1047 | 1047 | |
| 1048 | 1048 | // Then build a new array of top 10 editors by added text in the data structure needed for the chart. |
| 1049 | - return array_map(function ($editor) use ($topTenTotalAdded) { |
|
| 1049 | + return array_map(function($editor) use ($topTenTotalAdded) { |
|
| 1050 | 1050 | $added = $this->editors[$editor]['added']; |
| 1051 | 1051 | return [ |
| 1052 | 1052 | 'label' => $editor, |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | $rendered = str_replace('"', '\"', trim($rendered)); |
| 104 | 104 | |
| 105 | 105 | // Uglify temporary file. |
| 106 | - $tmpFile = sys_get_temp_dir() . '/xtools_articleinfo_gadget.js'; |
|
| 106 | + $tmpFile = sys_get_temp_dir().'/xtools_articleinfo_gadget.js'; |
|
| 107 | 107 | $script = "echo \"$rendered\" | tee $tmpFile >/dev/null && "; |
| 108 | 108 | $script .= $this->get('kernel')->getProjectDir(). |
| 109 | - "/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle " . |
|
| 109 | + "/node_modules/uglify-es/bin/uglifyjs $tmpFile --mangle ". |
|
| 110 | 110 | "&& rm $tmpFile >/dev/null"; |
| 111 | 111 | $process = new Process($script); |
| 112 | 112 | $process->run(); |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | $rendered = str_replace('\"', '"', trim($rendered)); |
| 126 | 126 | |
| 127 | 127 | // Add comment after uglifying since it removes comments. |
| 128 | - $rendered = "/**\n * This code was automatically generated and should not " . |
|
| 129 | - "be manually edited.\n * For updates, please copy and paste from " . |
|
| 130 | - $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL) . |
|
| 131 | - "\n * Released under GPL v3 license.\n */\n" . $rendered; |
|
| 128 | + $rendered = "/**\n * This code was automatically generated and should not ". |
|
| 129 | + "be manually edited.\n * For updates, please copy and paste from ". |
|
| 130 | + $this->generateUrl('ArticleInfoGadget', ['uglify' => 1], UrlGeneratorInterface::ABSOLUTE_URL). |
|
| 131 | + "\n * Released under GPL v3 license.\n */\n".$rendered; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $response = new Response($rendered); |