@@ -157,14 +157,14 @@ |
||
| 157 | 157 | |
| 158 | 158 | $revertEntries = array_filter( |
| 159 | 159 | $this->getTools($project), |
| 160 | - function ($tool) { |
|
| 160 | + function($tool) { |
|
| 161 | 161 | return isset($tool['revert']); |
| 162 | 162 | } |
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | 165 | // If 'revert' is set to `true`, then use 'regex' as the regular expression, |
| 166 | 166 | // otherwise 'revert' is assumed to be the regex string. |
| 167 | - $this->revertTools[$projectDomain] = array_map(function ($revertTool) { |
|
| 167 | + $this->revertTools[$projectDomain] = array_map(function($revertTool) { |
|
| 168 | 168 | return [ |
| 169 | 169 | 'link' => $revertTool['link'], |
| 170 | 170 | 'regex' => $revertTool['revert'] === true ? $revertTool['regex'] : $revertTool['revert'], |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | private function getEditsFromRevs(array $revs) |
| 243 | 243 | { |
| 244 | - return array_map(function ($rev) { |
|
| 244 | + return array_map(function($rev) { |
|
| 245 | 245 | /* @var Page Page object to be passed to the Edit contructor. */ |
| 246 | 246 | $page = $this->getPageFromRev($rev); |
| 247 | 247 | $rev['user'] = $this->user; |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | public function getToolsTotal() |
| 306 | 306 | { |
| 307 | 307 | if (!is_int($this->toolsTotal)) { |
| 308 | - $this->toolsTotal = array_reduce($this->getToolCounts(), function ($a, $b) { |
|
| 309 | - return $a + $b['count']; |
|
| 308 | + $this->toolsTotal = array_reduce($this->getToolCounts(), function($a, $b) { |
|
| 309 | + return $a+$b['count']; |
|
| 310 | 310 | }); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | $isSection = preg_match_all("/^\/\* (.*?) \*\//", $summary, $sectionMatch); |
| 282 | 282 | |
| 283 | 283 | if ($isSection && isset($page)) { |
| 284 | - $pageUrl = $project->getUrl(false) . str_replace( |
|
| 284 | + $pageUrl = $project->getUrl(false).str_replace( |
|
| 285 | 285 | '$1', |
| 286 | 286 | $page->getTitle($useUnnormalizedPageTitle), |
| 287 | 287 | $project->getArticlePath() |
@@ -291,8 +291,8 @@ discard block |
||
| 291 | 291 | // Must have underscores for the link to properly go to the section. |
| 292 | 292 | $sectionTitleLink = htmlspecialchars(str_replace(' ', '_', $sectionTitle)); |
| 293 | 293 | |
| 294 | - $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>" . |
|
| 295 | - "<em class='text-muted'>" . htmlspecialchars($sectionTitle) . ":</em> "; |
|
| 294 | + $sectionWikitext = "<a target='_blank' href='$pageUrl#$sectionTitleLink'>→</a>". |
|
| 295 | + "<em class='text-muted'>".htmlspecialchars($sectionTitle).":</em> "; |
|
| 296 | 296 | $summary = str_replace($sectionMatch[0][0], $sectionWikitext, $summary); |
| 297 | 297 | } |
| 298 | 298 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | 308 | // Use normalized page title (underscored, capitalized). |
| 309 | - $pageUrl = $project->getUrl(false) . str_replace( |
|
| 309 | + $pageUrl = $project->getUrl(false).str_replace( |
|
| 310 | 310 | '$1', |
| 311 | 311 | ucfirst(str_replace(' ', '_', $wikiLinkPath)), |
| 312 | 312 | $project->getArticlePath() |
@@ -344,8 +344,8 @@ discard block |
||
| 344 | 344 | public function getDiffUrl() |
| 345 | 345 | { |
| 346 | 346 | $project = $this->getProject(); |
| 347 | - $path = str_replace('$1', 'Special:Diff/' . $this->id, $project->getArticlePath()); |
|
| 348 | - return rtrim($project->getUrl(), '/') . $path; |
|
| 347 | + $path = str_replace('$1', 'Special:Diff/'.$this->id, $project->getArticlePath()); |
|
| 348 | + return rtrim($project->getUrl(), '/').$path; |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | public function getPermaUrl() |
| 356 | 356 | { |
| 357 | 357 | $project = $this->getProject(); |
| 358 | - $path = str_replace('$1', 'Special:PermaLink/' . $this->id, $project->getArticlePath()); |
|
| 359 | - return rtrim($project->getUrl(), '/') . $path; |
|
| 358 | + $path = str_replace('$1', 'Special:PermaLink/'.$this->id, $project->getArticlePath()); |
|
| 359 | + return rtrim($project->getUrl(), '/').$path; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | public function isAutomated(Container $container) |
| 390 | 390 | { |
| 391 | - return (bool) $this->getTool($container); |
|
| 391 | + return (bool)$this->getTool($container); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | /** |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | public function requestTime() |
| 112 | 112 | { |
| 113 | 113 | if (!isset($this->requestTime)) { |
| 114 | - $this->requestTime = microtime(true) - $this->getRequest()->server->get('REQUEST_TIME_FLOAT'); |
|
| 114 | + $this->requestTime = microtime(true)-$this->getRequest()->server->get('REQUEST_TIME_FLOAT'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | return $this->requestTime; |
@@ -674,15 +674,15 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | if ($seconds >= 86400) { |
| 676 | 676 | // Over a day |
| 677 | - $val = (int) floor($seconds / 86400); |
|
| 677 | + $val = (int)floor($seconds / 86400); |
|
| 678 | 678 | $key = 'days'; |
| 679 | 679 | } elseif ($seconds >= 3600) { |
| 680 | 680 | // Over an hour, less than a day |
| 681 | - $val = (int) floor($seconds / 3600); |
|
| 681 | + $val = (int)floor($seconds / 3600); |
|
| 682 | 682 | $key = 'hours'; |
| 683 | 683 | } elseif ($seconds >= 60) { |
| 684 | 684 | // Over a minute, less than an hour |
| 685 | - $val = (int) floor($seconds / 60); |
|
| 685 | + $val = (int)floor($seconds / 60); |
|
| 686 | 686 | $key = 'minutes'; |
| 687 | 687 | } |
| 688 | 688 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | // supply as the OFFSET. |
| 152 | 152 | $limitClause = ''; |
| 153 | 153 | if (intval($limit) > 0 && isset($numRevisions)) { |
| 154 | - $offset = $numRevisions - $limit; |
|
| 154 | + $offset = $numRevisions-$limit; |
|
| 155 | 155 | $limitClause = "LIMIT $offset, $limit"; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $time2 = time(); |
| 290 | 290 | |
| 291 | 291 | // If it took over 5 seconds, cache the result for 20 minutes. |
| 292 | - if ($time2 - $time1 > 5) { |
|
| 292 | + if ($time2-$time1 > 5) { |
|
| 293 | 293 | $this->setCache($cacheKey, $result, 'PT20M'); |
| 294 | 294 | } |
| 295 | 295 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | $wikidataId = ltrim($page->getWikidataId(), 'Q'); |
| 410 | 410 | |
| 411 | - $sql = "SELECT " . ($count ? 'COUNT(*) AS count' : '*') . " |
|
| 411 | + $sql = "SELECT ".($count ? 'COUNT(*) AS count' : '*')." |
|
| 412 | 412 | FROM wikidatawiki_p.wb_items_per_site |
| 413 | 413 | WHERE ips_item_id = :wikidataId"; |
| 414 | 414 | |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | 'wikidataId' => $wikidataId, |
| 417 | 417 | ])->fetchAll(); |
| 418 | 418 | |
| 419 | - return $count ? (int) $result[0]['count'] : $result; |
|
| 419 | + return $count ? (int)$result[0]['count'] : $result; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | // Transform to associative array by 'type' |
| 456 | 456 | foreach ($res as $row) { |
| 457 | - $data[$row['type'] . '_count'] = $row['value']; |
|
| 457 | + $data[$row['type'].'_count'] = $row['value']; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | return $data; |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | $project = $page->getProject()->getDomain(); |
| 498 | 498 | |
| 499 | - $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/' . |
|
| 499 | + $url = 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/'. |
|
| 500 | 500 | "$project/all-access/user/$title/daily/$start/$end"; |
| 501 | 501 | |
| 502 | 502 | $res = $client->request('GET', $url); |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | $normalized = []; |
| 569 | 569 | if (isset($result['query']['normalized'])) { |
| 570 | 570 | array_map( |
| 571 | - function ($e) use (&$normalized) { |
|
| 571 | + function($e) use (&$normalized) { |
|
| 572 | 572 | $normalized[$e['to']] = $e['from']; |
| 573 | 573 | }, |
| 574 | 574 | $result['query']['normalized'] |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $response->setEncodingOptions(JSON_NUMERIC_CHECK); |
| 320 | 320 | |
| 321 | 321 | $res['automated_editcount'] = $this->autoEdits->getAutomatedCount(); |
| 322 | - $res['nonautomated_editcount'] = $res['total_editcount'] - $res['automated_editcount']; |
|
| 322 | + $res['nonautomated_editcount'] = $res['total_editcount']-$res['automated_editcount']; |
|
| 323 | 323 | |
| 324 | 324 | if ($tools != '') { |
| 325 | 325 | $tools = $this->autoEdits->getToolCounts(); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | $namespaces = $this->project->getNamespaces(); |
| 368 | 368 | |
| 369 | - $ret['nonautomated_edits'] = array_map(function ($rev) use ($namespaces) { |
|
| 369 | + $ret['nonautomated_edits'] = array_map(function($rev) use ($namespaces) { |
|
| 370 | 370 | $pageTitle = $rev['page_title']; |
| 371 | 371 | if ((int)$rev['page_namespace'] === 0) { |
| 372 | 372 | $fullPageTitle = $pageTitle; |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | $namespaces = $this->project->getNamespaces(); |
| 422 | 422 | |
| 423 | - $ret['nonautomated_edits'] = array_map(function ($rev) use ($namespaces) { |
|
| 423 | + $ret['nonautomated_edits'] = array_map(function($rev) use ($namespaces) { |
|
| 424 | 424 | $pageTitle = $rev['page_title']; |
| 425 | 425 | if ((int)$rev['page_namespace'] === 0) { |
| 426 | 426 | $fullPageTitle = $pageTitle; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Find the path, and complain if English doesn't exist. |
| 75 | - $path = $this->container->getParameter('kernel.root_dir') . '/../i18n'; |
|
| 75 | + $path = $this->container->getParameter('kernel.root_dir').'/../i18n'; |
|
| 76 | 76 | if (!file_exists("$path/en.json")) { |
| 77 | 77 | throw new Exception("Language directory doesn't exist: $path"); |
| 78 | 78 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $messageFiles = glob($this->container->getParameter('kernel.root_dir').'/../i18n/*.json'); |
| 128 | 128 | |
| 129 | 129 | $languages = array_values(array_unique(array_map( |
| 130 | - function ($filename) { |
|
| 130 | + function($filename) { |
|
| 131 | 131 | return basename($filename, '.json'); |
| 132 | 132 | }, |
| 133 | 133 | $messageFiles |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | $this->getIntuition()->getLangFallbacks($this->getLang()) |
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | - return array_filter($fallbacks, function ($lang) use ($i18nPath) { |
|
| 172 | + return array_filter($fallbacks, function($lang) use ($i18nPath) { |
|
| 173 | 173 | return is_file($i18nPath.$lang.'.json'); |
| 174 | 174 | }); |
| 175 | 175 | } |
@@ -91,20 +91,20 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | // MULTIPLIERS (to review) |
| 93 | 93 | $multipliers = [ |
| 94 | - 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
| 95 | - 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
| 96 | - 'user-page-mult' => 0.1, # 0 if = |
|
| 97 | - 'patrols-mult' => 1, # 0 if = |
|
| 98 | - 'blocks-mult' => 1.4, # 0 if = 10 |
|
| 94 | + 'account-age-mult' => 1.25, # 0 if = 365 jours |
|
| 95 | + 'edit-count-mult' => 1.25, # 0 if = 10 000 |
|
| 96 | + 'user-page-mult' => 0.1, # 0 if = |
|
| 97 | + 'patrols-mult' => 1, # 0 if = |
|
| 98 | + 'blocks-mult' => 1.4, # 0 if = 10 |
|
| 99 | 99 | 'afd-mult' => 1.15, |
| 100 | - 'recent-activity-mult' => 0.9, # 0 if = |
|
| 100 | + 'recent-activity-mult' => 0.9, # 0 if = |
|
| 101 | 101 | 'aiv-mult' => 1.15, |
| 102 | - 'edit-summaries-mult' => 0.8, # 0 if = |
|
| 103 | - 'namespaces-mult' => 1.0, # 0 if = |
|
| 104 | - 'pages-created-live-mult' => 1.4, # 0 if = |
|
| 105 | - 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
| 106 | - 'rpp-mult' => 1.15, # 0 if = |
|
| 107 | - 'user-rights-mult' => 0.75, # 0 if = |
|
| 102 | + 'edit-summaries-mult' => 0.8, # 0 if = |
|
| 103 | + 'namespaces-mult' => 1.0, # 0 if = |
|
| 104 | + 'pages-created-live-mult' => 1.4, # 0 if = |
|
| 105 | + 'pages-created-deleted-mult' => 1.4, # 0 if = |
|
| 106 | + 'rpp-mult' => 1.15, # 0 if = |
|
| 107 | + 'user-rights-mult' => 0.75, # 0 if = |
|
| 108 | 108 | ]; |
| 109 | 109 | |
| 110 | 110 | // Grab the connection to the replica database (which is separate from the above) |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $now = new DateTime(); |
| 186 | 186 | $date = new DateTime($value); |
| 187 | 187 | $diff = $date->diff($now); |
| 188 | - $formula = 365 * $diff->format('%y') + 30 * $diff->format('%m') + $diff->format('%d'); |
|
| 188 | + $formula = 365 * $diff->format('%y')+30 * $diff->format('%m')+$diff->format('%d'); |
|
| 189 | 189 | if ($formula < 365) { |
| 190 | 190 | $multipliers["account-age-mult"] = 0; |
| 191 | 191 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $multiplierKey = $row['source'] . '-mult'; |
|
| 196 | + $multiplierKey = $row['source'].'-mult'; |
|
| 197 | 197 | $multiplier = isset($multipliers[$multiplierKey]) ? $multipliers[$multiplierKey] : 1; |
| 198 | 198 | $score = max(min($value * $multiplier, 100), -100); |
| 199 | 199 | $master[$key]['mult'] = $multiplier; |
@@ -177,7 +177,7 @@ |
||
| 177 | 177 | // 'Category:', which sometimes is used cross-wiki (because it still works). |
| 178 | 178 | $normalized = false; |
| 179 | 179 | $nsName = $this->project->getNamespaces()[14].':'; |
| 180 | - $this->categories = array_map(function ($category) use ($nsName, &$normalized) { |
|
| 180 | + $this->categories = array_map(function($category) use ($nsName, &$normalized) { |
|
| 181 | 181 | if (strpos($category, $nsName) === 0 || strpos($category, 'Category:') === 0) { |
| 182 | 182 | $normalized = true; |
| 183 | 183 | } |