@@ -380,7 +380,6 @@ |
||
| 380 | 380 | |
| 381 | 381 | /** |
| 382 | 382 | * Get the size of the diff |
| 383 | - * @param int $rev The index of the revision within $this->pageHistory |
|
| 384 | 383 | * @return int Size of the diff |
| 385 | 384 | */ |
| 386 | 385 | private function getDiffSize($revIndex) |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | $article = $request->query->get('article'); |
| 56 | 56 | |
| 57 | 57 | if ($projectQuery != '' && $article != '') { |
| 58 | - return $this->redirectToRoute('ArticleInfoResult', [ 'project'=>$projectQuery, 'article' => $article ]); |
|
| 58 | + return $this->redirectToRoute('ArticleInfoResult', ['project'=>$projectQuery, 'article' => $article]); |
|
| 59 | 59 | } elseif ($article != '') { |
| 60 | - return $this->redirectToRoute('ArticleInfoProject', [ 'project'=>$projectQuery ]); |
|
| 60 | + return $this->redirectToRoute('ArticleInfoProject', ['project'=>$projectQuery]); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | return $this->render('articleInfo/index.html.twig', [ |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | 'url' => $basicInfo['fullurl'] |
| 102 | 102 | ]; |
| 103 | 103 | |
| 104 | - $this->pageInfo['watchers'] = ( isset($basicInfo['watchers']) ) ? $basicInfo['watchers'] : "< 30"; |
|
| 104 | + $this->pageInfo['watchers'] = (isset($basicInfo['watchers'])) ? $basicInfo['watchers'] : "< 30"; |
|
| 105 | 105 | |
| 106 | 106 | $pageProps = isset($basicInfo['pageprops']) ? $basicInfo['pageprops'] : []; |
| 107 | 107 | |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | private function getRevCount() |
| 166 | 166 | { |
| 167 | - $query = "SELECT COUNT(*) AS count FROM " . $this->revisionTable |
|
| 168 | - . " WHERE rev_page = '" . $this->pageInfo['id'] . "'"; |
|
| 167 | + $query = "SELECT COUNT(*) AS count FROM ".$this->revisionTable |
|
| 168 | + . " WHERE rev_page = '".$this->pageInfo['id']."'"; |
|
| 169 | 169 | $res = $this->conn->query($query)->fetchAll(); |
| 170 | 170 | return $res[0]['count']; |
| 171 | 171 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | FROM $this->revisionTable |
| 198 | 198 | LEFT JOIN $userGroupsTable ON rev_user = ug_user |
| 199 | 199 | LEFT JOIN $userFromerGroupsTable ON rev_user = ufg_user |
| 200 | - WHERE rev_page = " . $this->pageInfo['id'] . " AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
| 200 | + WHERE rev_page = ".$this->pageInfo['id']." AND (ug_group = 'bot' OR ufg_group = 'bot') |
|
| 201 | 201 | GROUP BY rev_user_text"; |
| 202 | 202 | $res = $this->conn->query($query)->fetchAll(); |
| 203 | 203 | |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | $sum = 0; |
| 207 | 207 | foreach ($res as $bot) { |
| 208 | 208 | $bots[$bot['username']] = [ |
| 209 | - 'count' => (int) $bot['count'], |
|
| 209 | + 'count' => (int)$bot['count'], |
|
| 210 | 210 | 'current' => $bot['current'] === 'bot' |
| 211 | 211 | ]; |
| 212 | 212 | $sum += $bot['count']; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - uasort($bots, function ($a, $b) { |
|
| 216 | - return $b['count'] - $a['count']; |
|
| 215 | + uasort($bots, function($a, $b) { |
|
| 216 | + return $b['count']-$a['count']; |
|
| 217 | 217 | }); |
| 218 | 218 | |
| 219 | 219 | $this->pageInfo['general']['bot_revision_count'] = $sum; |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | if ($info['all'] > 1) { |
| 263 | 263 | // Number of seconds between first and last edit |
| 264 | - $secs = intval(strtotime($info['last']) - strtotime($info['first']) / $info['all']); |
|
| 264 | + $secs = intval(strtotime($info['last'])-strtotime($info['first']) / $info['all']); |
|
| 265 | 265 | |
| 266 | 266 | // Average time between edits (in days) |
| 267 | - $this->pageInfo['editors'][$editor]['atbe'] = $secs / ( 60 * 60 * 24 ); |
|
| 267 | + $this->pageInfo['editors'][$editor]['atbe'] = $secs / (60 * 60 * 24); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | if (count($info['sizes'])) { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | // First sort editors array by the amount of text they added |
| 281 | 281 | $topTenEditorsByAdded = $this->pageInfo['editors']; |
| 282 | - uasort($topTenEditorsByAdded, function ($a, $b) { |
|
| 282 | + uasort($topTenEditorsByAdded, function($a, $b) { |
|
| 283 | 283 | if ($a['added'] === $b['added']) { |
| 284 | 284 | return 0; |
| 285 | 285 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | |
| 289 | 289 | // Then build a new array of top 10 editors by added text, |
| 290 | 290 | // in the data structure needed for the chart |
| 291 | - $this->pageInfo['topTenEditorsByAdded'] = array_map(function ($editor) { |
|
| 291 | + $this->pageInfo['topTenEditorsByAdded'] = array_map(function($editor) { |
|
| 292 | 292 | $added = $this->pageInfo['editors'][$editor]['added']; |
| 293 | 293 | return [ |
| 294 | 294 | 'label' => $editor, |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | // Transform to associative array by 'type' |
| 336 | 336 | foreach ($res as $row) { |
| 337 | - $data[$row['type'] . '_count'] = $row['value']; |
|
| 337 | + $data[$row['type'].'_count'] = $row['value']; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | return $data; |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $title = str_replace(' ', '_', $this->pageInfo['title']); |
| 351 | 351 | $query = "SELECT log_action, log_type, log_timestamp AS timestamp |
| 352 | 352 | FROM $loggingTable |
| 353 | - WHERE log_namespace = '" . $this->pageInfo['namespace'] . "' |
|
| 353 | + WHERE log_namespace = '".$this->pageInfo['namespace']."' |
|
| 354 | 354 | AND log_title = '$title' AND log_timestamp > 1 |
| 355 | 355 | AND log_type IN ('delete', 'move', 'protect', 'stable')"; |
| 356 | 356 | $events = $this->conn->query($query)->fetchAll(); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | $conn = $this->container->get('doctrine')->getManager('replicas')->getConnection(); |
| 436 | 436 | $res = $conn->query($query)->fetchAll(); |
| 437 | 437 | |
| 438 | - $terms = array_map(function ($entry) { |
|
| 438 | + $terms = array_map(function($entry) { |
|
| 439 | 439 | return $entry['term']; |
| 440 | 440 | }, $res); |
| 441 | 441 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | 'prio' => 2, |
| 447 | 447 | 'name' => 'Wikidata', |
| 448 | 448 | 'notice' => "Label for language <em>$lang</em> is missing", // FIXME: i18n |
| 449 | - 'explanation' => "See: <a target='_blank' " . |
|
| 449 | + 'explanation' => "See: <a target='_blank' ". |
|
| 450 | 450 | "href='//www.wikidata.org/wiki/Help:Label'>Help:Label</a>", |
| 451 | 451 | ]; |
| 452 | 452 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | 'prio' => 3, |
| 456 | 456 | 'name' => 'Wikidata', |
| 457 | 457 | 'notice' => "Description for language <em>$lang</em> is missing", // FIXME: i18n |
| 458 | - 'explanation' => "See: <a target='_blank' " . |
|
| 458 | + 'explanation' => "See: <a target='_blank' ". |
|
| 459 | 459 | "href='//www.wikidata.org/wiki/Help:Description'>Help:Description</a>", |
| 460 | 460 | ]; |
| 461 | 461 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | $query = "SELECT rev_id, rev_parent_id, rev_user_text, rev_user, rev_timestamp, |
| 473 | 473 | rev_minor_edit, rev_len, rev_comment |
| 474 | 474 | FROM $this->revisionTable |
| 475 | - WHERE rev_page = '" . $this->pageInfo['id'] . "' AND rev_timestamp > 1 |
|
| 475 | + WHERE rev_page = '".$this->pageInfo['id']."' AND rev_timestamp > 1 |
|
| 476 | 476 | ORDER BY rev_timestamp"; |
| 477 | 477 | |
| 478 | 478 | $res = $this->conn->query($query)->fetchAll(); |
@@ -492,14 +492,14 @@ discard block |
||
| 492 | 492 | return $rev['rev_len']; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - $lastRev = $this->pageHistory[$revIndex - 1]; |
|
| 495 | + $lastRev = $this->pageHistory[$revIndex-1]; |
|
| 496 | 496 | |
| 497 | 497 | // TODO: Remove once T101631 is resolved |
| 498 | 498 | // Treat as zero change in size if rev_len of previous edit is missing |
| 499 | 499 | if ($lastRev['rev_len'] === null) { |
| 500 | 500 | return 0; |
| 501 | 501 | } else { |
| 502 | - return $rev['rev_len'] - $lastRev['rev_len']; |
|
| 502 | + return $rev['rev_len']-$lastRev['rev_len']; |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
@@ -520,12 +520,12 @@ discard block |
||
| 520 | 520 | // The month of the first edit. Used as a comparison when building the per-month data |
| 521 | 521 | $firstEditMonth = strtotime(date('Y-m-01, 00:00', strtotime($firstEdit['rev_timestamp']))); |
| 522 | 522 | |
| 523 | - $lastEdit = $this->pageHistory[ $revisionCount - 1 ]; |
|
| 524 | - $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[ $revisionCount - 2 ]; |
|
| 523 | + $lastEdit = $this->pageHistory[$revisionCount-1]; |
|
| 524 | + $secondLastEdit = $revisionCount === 1 ? $lastEdit : $this->pageHistory[$revisionCount-2]; |
|
| 525 | 525 | |
| 526 | 526 | // Now we can start our master array. This one will be HUGE! |
| 527 | 527 | $lastEditSize = ($revisionCount > 1) |
| 528 | - ? $lastEdit['rev_len'] - $secondLastEdit['rev_len'] |
|
| 528 | + ? $lastEdit['rev_len']-$secondLastEdit['rev_len'] |
|
| 529 | 529 | : $lastEdit['rev_len']; |
| 530 | 530 | $data = [ |
| 531 | 531 | 'general' => [ |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | // Increment year and month counts for all edits |
| 623 | 623 | $data['year_count'][$timestamp['year']]['all']++; |
| 624 | 624 | $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']++; |
| 625 | - $data['year_count'][$timestamp['year']]['size'] = (int) $rev['rev_len']; |
|
| 625 | + $data['year_count'][$timestamp['year']]['size'] = (int)$rev['rev_len']; |
|
| 626 | 626 | |
| 627 | 627 | $editsThisMonth = $data['year_count'][$timestamp['year']]['months'][$timestamp['month']]['all']; |
| 628 | 628 | if ($editsThisMonth > $data['max_edits_per_month']) { |
@@ -666,9 +666,9 @@ discard block |
||
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | // determine if the next revision was a revert |
| 669 | - $nextRevision = isset($this->pageHistory[$i + 1]) ? $this->pageHistory[$i + 1] : null; |
|
| 669 | + $nextRevision = isset($this->pageHistory[$i+1]) ? $this->pageHistory[$i+1] : null; |
|
| 670 | 670 | $nextRevisionIsRevert = $nextRevision && |
| 671 | - $this->getDiffSize($i + 1) === -$diffSize && |
|
| 671 | + $this->getDiffSize($i+1) === -$diffSize && |
|
| 672 | 672 | $this->aeh->isRevert($nextRevision['rev_comment']); |
| 673 | 673 | |
| 674 | 674 | // don't count this edit as content removal if the next edit reverted it |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | // Feel free to remove this, extend it, or make something more sophisticated. |
| 13 | 13 | if (isset($_SERVER['HTTP_CLIENT_IP']) |
| 14 | 14 | || isset($_SERVER['HTTP_X_FORWARDED_FOR']) |
| 15 | - || !( in_array(@$_SERVER['REMOTE_ADDR'], [ '127.0.0.1', 'fe80::1', '::1' ]) || php_sapi_name() === 'cli-server' ) |
|
| 15 | + || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server') |
|
| 16 | 16 | ) { |
| 17 | 17 | header('HTTP/1.0 403 Forbidden'); |
| 18 | 18 | exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.'); |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | $data = json_decode($file, true); |
| 16 | 16 | |
| 17 | 17 | // Output the contents to the piped file |
| 18 | -print ( "parameters: |
|
| 18 | +print ("parameters: |
|
| 19 | 19 | automated_tools:\r\n" ); |
| 20 | 20 | foreach ($data as $row) { |
| 21 | - print " - " . $row["name"] . ": '" . $row["regex"] . "'\r\n"; |
|
| 21 | + print " - ".$row["name"].": '".$row["regex"]."'\r\n"; |
|
| 22 | 22 | } |
| 23 | -print ( " |
|
| 23 | +print (" |
|
| 24 | 24 | |
| 25 | - semi-automated edits source: $url" ); |
|
| 25 | + semi-automated edits source: $url"); |
|
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | $title = str_replace(' ', '_', $title); |
| 13 | 13 | $client = new GuzzleHttp\Client(); |
| 14 | 14 | |
| 15 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . |
|
| 16 | - "$project/all-access/user/" . rawurlencode($title) . '/daily/' . $start . '/' . $end; |
|
| 15 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. |
|
| 16 | + "$project/all-access/user/".rawurlencode($title).'/daily/'.$start.'/'.$end; |
|
| 17 | 17 | |
| 18 | 18 | $res = $client->request('GET', $url); |
| 19 | 19 | return json_decode($res->getBody()->getContents()); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $data = $this->getLastDays($project, $title, $days); |
| 33 | 33 | |
| 34 | 34 | // FIXME: needs to handle gotchas |
| 35 | - return array_sum(array_map(function ($item) { |
|
| 35 | + return array_sum(array_map(function($item) { |
|
| 36 | 36 | return $item->views; |
| 37 | 37 | }, $data->items)); |
| 38 | 38 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // Find the path, and complain if English doesn't exist. |
| 48 | - $path = $this->container->getParameter("kernel.root_dir") . '/../i18n'; |
|
| 48 | + $path = $this->container->getParameter("kernel.root_dir").'/../i18n'; |
|
| 49 | 49 | if (!file_exists("$path/en.json")) { |
| 50 | 50 | throw new Exception("Language directory doesn't exist: $path"); |
| 51 | 51 | } |
@@ -72,7 +72,6 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Get a link to the given user's userpage, or to Special:Contribs if $username is an IP |
| 75 | - * @param string $username Username |
|
| 76 | 75 | * @param string $projectUrl Project domain and protocol such as https://en.wikipedia.org |
| 77 | 76 | * @param string [$label] The link text, defaults to $username |
| 78 | 77 | * @return string Markup |
@@ -176,7 +175,7 @@ discard block |
||
| 176 | 175 | /** |
| 177 | 176 | * Get links to pageviews tools for the given page |
| 178 | 177 | * @param string $title Title of page |
| 179 | - * @param string $projectUrl Project domain such as en.wikipedia.org |
|
| 178 | + * @param string $project Project domain such as en.wikipedia.org |
|
| 180 | 179 | * @return string Markup |
| 181 | 180 | */ |
| 182 | 181 | public function pageviewsLinks($title, $project) |
@@ -14,25 +14,25 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function intuitionMessage($message = "", $vars = []) |
| 16 | 16 | { |
| 17 | - return $this->getIntuition()->msg($message, [ "domain" => "xtools", "variables" => $vars ]); |
|
| 17 | + return $this->getIntuition()->msg($message, ["domain" => "xtools", "variables" => $vars]); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /*********************************** FUNCTIONS ***********************************/ |
| 21 | 21 | |
| 22 | 22 | public function getFunctions() |
| 23 | 23 | { |
| 24 | - $options = [ 'is_safe' => [ 'html']]; |
|
| 24 | + $options = ['is_safe' => ['html']]; |
|
| 25 | 25 | return [ |
| 26 | - new Twig_SimpleFunction('wiki_link', [ $this, 'wikiLink' ], $options), |
|
| 27 | - new Twig_SimpleFunction('user_link', [ $this, 'userLink' ], $options), |
|
| 28 | - new Twig_SimpleFunction('user_log_link', [ $this, 'userLogLink' ], $options), |
|
| 29 | - new Twig_SimpleFunction('group_link', [ $this, 'groupLink' ], $options), |
|
| 30 | - new Twig_SimpleFunction('wiki_history_link', [ $this, 'wikiHistoryLink' ], $options), |
|
| 31 | - new Twig_SimpleFunction('wiki_log_link', [ $this, 'wikiLogLink' ], $options), |
|
| 32 | - new Twig_SimpleFunction('pageviews_links', [ $this, 'pageviewsLinks' ], $options), |
|
| 33 | - new Twig_SimpleFunction('diff_link', [ $this, 'diffLink' ], $options), |
|
| 34 | - new Twig_SimpleFunction('perma_link', [ $this, 'permaLink' ], $options), |
|
| 35 | - new Twig_SimpleFunction('edit_link', [ $this, 'editLink' ], $options), |
|
| 26 | + new Twig_SimpleFunction('wiki_link', [$this, 'wikiLink'], $options), |
|
| 27 | + new Twig_SimpleFunction('user_link', [$this, 'userLink'], $options), |
|
| 28 | + new Twig_SimpleFunction('user_log_link', [$this, 'userLogLink'], $options), |
|
| 29 | + new Twig_SimpleFunction('group_link', [$this, 'groupLink'], $options), |
|
| 30 | + new Twig_SimpleFunction('wiki_history_link', [$this, 'wikiHistoryLink'], $options), |
|
| 31 | + new Twig_SimpleFunction('wiki_log_link', [$this, 'wikiLogLink'], $options), |
|
| 32 | + new Twig_SimpleFunction('pageviews_links', [$this, 'pageviewsLinks'], $options), |
|
| 33 | + new Twig_SimpleFunction('diff_link', [$this, 'diffLink'], $options), |
|
| 34 | + new Twig_SimpleFunction('perma_link', [$this, 'permaLink'], $options), |
|
| 35 | + new Twig_SimpleFunction('edit_link', [$this, 'editLink'], $options), |
|
| 36 | 36 | ]; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | public function getFilters() |
| 245 | 245 | { |
| 246 | 246 | return [ |
| 247 | - new \Twig_SimpleFilter('diff_format', [ $this, 'diffFormat' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 248 | - new \Twig_SimpleFilter('wikify_comment', [ $this, 'wikifyComment' ], [ 'is_safe' => [ 'html' ] ]), |
|
| 247 | + new \Twig_SimpleFilter('diff_format', [$this, 'diffFormat'], ['is_safe' => ['html']]), |
|
| 248 | + new \Twig_SimpleFilter('wikify_comment', [$this, 'wikifyComment'], ['is_safe' => ['html']]), |
|
| 249 | 249 | ]; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if ($isSection) { |
| 285 | 285 | $sectionTitle = $sectionMatch[1][0]; |
| 286 | 286 | $sectionTitleLink = str_replace(' ', '_', $sectionTitle); |
| 287 | - $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>" . |
|
| 287 | + $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>→</a>". |
|
| 288 | 288 | "<em class='text-muted'>$sectionTitle:</em> "; |
| 289 | 289 | $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext); |
| 290 | 290 | } |
@@ -176,7 +176,7 @@ |
||
| 176 | 176 | |
| 177 | 177 | // Iterate over query results, loading each user id into the array |
| 178 | 178 | while ($row = $res->fetch()) { |
| 179 | - $adminIdArr[] = $row["user_id"] ; |
|
| 179 | + $adminIdArr[] = $row["user_id"]; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Set the query results to be useful in a sql statement. |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | /** @var string[] Basic metadata about the project */ |
| 15 | 15 | protected $metadata; |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param string $nameOrUrl |
|
| 19 | + */ |
|
| 17 | 20 | public function __construct($nameOrUrl) |
| 18 | 21 | { |
| 19 | 22 | $this->nameUnnormalized = $nameOrUrl; |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | */ |
| 56 | 56 | public function getUrl() |
| 57 | 57 | { |
| 58 | - return rtrim($this->getMetadata()['url'], '/') . '/'; |
|
| 58 | + return rtrim($this->getMetadata()['url'], '/').'/'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $apiPath = $this->container->getParameter('api_path'); |
| 40 | 40 | |
| 41 | 41 | try { |
| 42 | - $this->api = MediawikiApi::newFromApiEndpoint($normalizedProject . $apiPath); |
|
| 42 | + $this->api = MediawikiApi::newFromApiEndpoint($normalizedProject.$apiPath); |
|
| 43 | 43 | } catch (Exception $e) { |
| 44 | 44 | // Do nothing... |
| 45 | 45 | } catch (FatalErrorException $e) { |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | throw new Exception("Unable to find project '$project'"); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - $cacheKey = "siteinfo." . str_replace('/', '_', $normalizedProject); |
|
| 71 | + $cacheKey = "siteinfo.".str_replace('/', '_', $normalizedProject); |
|
| 72 | 72 | if ($this->cacheHas($cacheKey)) { |
| 73 | 73 | return $this->cacheGet($cacheKey); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $this->setUp($normalizedProject); |
| 77 | - $params = [ 'meta'=>'siteinfo', 'siprop'=>'general|namespaces' ]; |
|
| 77 | + $params = ['meta'=>'siteinfo', 'siprop'=>'general|namespaces']; |
|
| 78 | 78 | $query = new SimpleRequest('query', $params); |
| 79 | 79 | |
| 80 | 80 | $result = [ |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | public function groups($project, $username) |
| 139 | 139 | { |
| 140 | 140 | $this->setUp($project); |
| 141 | - $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ]; |
|
| 141 | + $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"]; |
|
| 142 | 142 | $query = new SimpleRequest('query', $params); |
| 143 | 143 | $result = []; |
| 144 | 144 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | public function globalGroups($project, $username) |
| 158 | 158 | { |
| 159 | 159 | $this->setUp($project); |
| 160 | - $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ]; |
|
| 160 | + $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"]; |
|
| 161 | 161 | $query = new SimpleRequest('query', $params); |
| 162 | 162 | $result = []; |
| 163 | 163 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $groups[] = "B"; |
| 206 | 206 | } |
| 207 | 207 | if (in_array("steward", $admin["groups"])) { |
| 208 | - $groups[] = "S" ; |
|
| 208 | + $groups[] = "S"; |
|
| 209 | 209 | } |
| 210 | 210 | if (in_array("checkuser", $admin["groups"])) { |
| 211 | 211 | $groups[] = "CU"; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | if (in_array("bot", $admin["groups"])) { |
| 217 | 217 | $groups[] = "Bot"; |
| 218 | 218 | } |
| 219 | - $result[ $admin["name"] ] = [ |
|
| 219 | + $result[$admin["name"]] = [ |
|
| 220 | 220 | "groups" => implode('/', $groups) |
| 221 | 221 | ]; |
| 222 | 222 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | $normalized = []; |
| 292 | 292 | if (isset($result['query']['normalized'])) { |
| 293 | 293 | array_map( |
| 294 | - function ($e) use (&$normalized) { |
|
| 294 | + function($e) use (&$normalized) { |
|
| 295 | 295 | $normalized[$e['to']] = $e['from']; |
| 296 | 296 | }, |
| 297 | 297 | $result['query']['normalized'] |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | ]; |
| 338 | 338 | |
| 339 | 339 | // get assessments for this page from the API |
| 340 | - $assessments = $this->massApi($params, $project, function ($data) { |
|
| 340 | + $assessments = $this->massApi($params, $project, function($data) { |
|
| 341 | 341 | return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : []; |
| 342 | 342 | }, 'pacontinue')['pages']; |
| 343 | 343 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | $classAttrs = $config['class']['Unknown']; |
| 362 | 362 | $assessment['class']['value'] = '???'; |
| 363 | 363 | $assessment['class']['category'] = $classAttrs['category']; |
| 364 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge']; |
|
| 364 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge']; |
|
| 365 | 365 | } else { |
| 366 | 366 | $classAttrs = $config['class'][$classValue]; |
| 367 | 367 | $assessment['class'] = [ |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | // add full URL to badge icon |
| 374 | 374 | if ($classAttrs['badge'] !== '') { |
| 375 | - $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" . |
|
| 375 | + $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". |
|
| 376 | 376 | $classAttrs['badge']; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -421,9 +421,9 @@ discard block |
||
| 421 | 421 | $config = $this->getAssessmentsConfig(); |
| 422 | 422 | |
| 423 | 423 | if (isset($config[$project]['class'][$class])) { |
| 424 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge']; |
|
| 424 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge']; |
|
| 425 | 425 | } elseif (isset($config[$project]['class']['Unknown'])) { |
| 426 | - return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge']; |
|
| 426 | + return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge']; |
|
| 427 | 427 | } else { |
| 428 | 428 | return ""; |
| 429 | 429 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | $query = FluentRequest::factory()->setAction('query')->setParams($requestData); |
| 517 | 517 | $innerPromise = $this->api->getRequestAsync($query); |
| 518 | 518 | |
| 519 | - $innerPromise->then(function ($result) use (&$data) { |
|
| 519 | + $innerPromise->then(function($result) use (&$data) { |
|
| 520 | 520 | // some failures come back as 200s, so we still resolve and let the outer function handle it |
| 521 | 521 | if (isset($result['error']) || !isset($result['query'])) { |
| 522 | 522 | return $data['promise']->resolve($data); |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | * Get a list of namespaces on the given project. |
| 178 | 178 | * |
| 179 | 179 | * @param string $project such as en.wikipedia.org |
| 180 | - * @return string[] Array of namespace IDs (keys) to names (values). |
|
| 180 | + * @return string Array of namespace IDs (keys) to names (values). |
|
| 181 | 181 | */ |
| 182 | 182 | public function namespaces($project) |
| 183 | 183 | { |