@@ -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 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false) |
51 | 51 | { |
52 | - $this->fulfilled = (bool) $fulfilled; |
|
53 | - $this->testMessage = (string) $testMessage; |
|
54 | - $this->helpHtml = (string) $helpHtml; |
|
55 | - $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText; |
|
56 | - $this->optional = (bool) $optional; |
|
52 | + $this->fulfilled = (bool)$fulfilled; |
|
53 | + $this->testMessage = (string)$testMessage; |
|
54 | + $this->helpHtml = (string)$helpHtml; |
|
55 | + $this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string)$helpText; |
|
56 | + $this->optional = (bool)$optional; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | ); |
545 | 545 | } |
546 | 546 | |
547 | - $pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null; |
|
547 | + $pcreVersion = defined('PCRE_VERSION') ? (float)PCRE_VERSION : null; |
|
548 | 548 | |
549 | 549 | $this->addRequirement( |
550 | 550 | null !== $pcreVersion, |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | $unit = ''; |
784 | 784 | if (!ctype_digit($size)) { |
785 | 785 | $unit = strtolower(substr($size, -1, 1)); |
786 | - $size = (int) substr($size, 0, -1); |
|
786 | + $size = (int)substr($size, 0, -1); |
|
787 | 787 | } |
788 | 788 | switch ($unit) { |
789 | 789 | case 'g': |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | case 'k': |
794 | 794 | return $size * 1024; |
795 | 795 | default: |
796 | - return (int) $size; |
|
796 | + return (int)$size; |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | continue; |
816 | 816 | } |
817 | 817 | |
818 | - return (int) $package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; |
|
818 | + return (int)$package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | return false; |
@@ -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. |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | 'username' => $username, |
57 | 57 | ]); |
58 | 58 | } elseif ($projectQuery != "") { |
59 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$projectQuery ]); |
|
59 | + return $this->redirectToRoute("PagesProject", ['project'=>$projectQuery]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // set default wiki so we can populate the namespace selector |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // show error message and redirect back to default project |
75 | 75 | $this->addFlash("notice", [$e->getMessage()]); |
76 | 76 | $project = $this->container->getParameter('default_project'); |
77 | - return $this->redirectToRoute("PagesProject", [ 'project'=>$project ]); |
|
77 | + return $this->redirectToRoute("PagesProject", ['project'=>$project]); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Otherwise fall through. |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | JOIN $revisionTable ON page_id = rev_page |
184 | 184 | $paJoin |
185 | 185 | WHERE $whereRev AND rev_parent_id = '0' $namespaceConditionRev $redirectCondition |
186 | - " . ($hasPageAssessments ? "GROUP BY rev_page" : "") . " |
|
186 | + ".($hasPageAssessments ? "GROUP BY rev_page" : "")." |
|
187 | 187 | ) |
188 | 188 | |
189 | 189 | UNION |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | } |
268 | 268 | |
269 | 269 | if ($total < 1) { |
270 | - $this->addFlash("notice", [ "noresult", $username ]); |
|
271 | - return $this->redirectToRoute("PagesProject", [ "project"=>$project ]); |
|
270 | + $this->addFlash("notice", ["noresult", $username]); |
|
271 | + return $this->redirectToRoute("PagesProject", ["project"=>$project]); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | ksort($pagesByNamespaceByDate); |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $username = $request->query->get('username'); |
32 | 32 | |
33 | 33 | if ($projectQuery != "" && $username != "") { |
34 | - $routeParams = [ 'project'=>$projectQuery, 'username' => $username ]; |
|
34 | + $routeParams = ['project'=>$projectQuery, 'username' => $username]; |
|
35 | 35 | return $this->redirectToRoute("SimpleEditCounterResult", $routeParams); |
36 | 36 | } elseif ($projectQuery != "") { |
37 | - return $this->redirectToRoute("SimpleEditCounterProject", [ 'project'=>$projectQuery ]); |
|
37 | + return $this->redirectToRoute("SimpleEditCounterProject", ['project'=>$projectQuery]); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // Otherwise fall through. |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | $resultQuery->execute(); |
90 | 90 | |
91 | 91 | if ($resultQuery->errorCode() > 0) { |
92 | - $this->addFlash("notice", [ "noresult", $username ]); |
|
93 | - return $this->redirectToRoute("SimpleEditCounterProject", [ "project"=>$project ]); |
|
92 | + $this->addFlash("notice", ["noresult", $username]); |
|
93 | + return $this->redirectToRoute("SimpleEditCounterProject", ["project"=>$project]); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | // Fetch the result data |
@@ -114,16 +114,16 @@ discard block |
||
114 | 114 | $rev = $row["value"]; |
115 | 115 | } |
116 | 116 | if ($row["source"] == "groups") { |
117 | - $groups .= $row["value"]. ", "; |
|
117 | + $groups .= $row["value"].", "; |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Unknown user - If the user is created the $results variable will have 3 entries. |
122 | 122 | // This is a workaround to detect non-existent IPs. |
123 | 123 | if (count($results) < 3 && $arch == 0 && $rev == 0) { |
124 | - $this->addFlash('notice', [ "noresult", $username ]); |
|
124 | + $this->addFlash('notice', ["noresult", $username]); |
|
125 | 125 | |
126 | - return $this->redirectToRoute("SimpleEditCounterProject", [ "project"=>$project ]); |
|
126 | + return $this->redirectToRoute("SimpleEditCounterProject", ["project"=>$project]); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // Remove the last comma and space |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'project_url' => $url, |
153 | 153 | 'id' => $id, |
154 | 154 | 'arch' => $arch, |
155 | - 'rev' => $rev + $arch, |
|
155 | + 'rev' => $rev+$arch, |
|
156 | 156 | 'live' => $rev, |
157 | 157 | 'groups' => $groups, |
158 | 158 | 'globalGroups' => $globalGroups, |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->dbName = $dbName; |
72 | 72 | $this->url = $url; |
73 | 73 | |
74 | - return [ 'dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang ]; |
|
74 | + return ['dbName' => $dbName, 'wikiName' => $wikiName, 'url' => $url, 'lang' => $lang]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // Create the query we're going to run against the meta database |
100 | 100 | $wikiQuery = $this->client->createQueryBuilder(); |
101 | 101 | $wikiQuery |
102 | - ->select([ 'dbname', 'name', 'url', 'lang' ]) |
|
102 | + ->select(['dbname', 'name', 'url', 'lang']) |
|
103 | 103 | ->from('wiki') |
104 | 104 | ->where($wikiQuery->expr()->eq('dbname', ':project')) |
105 | 105 | // The meta database will have the project's URL stored as https://en.wikipedia.org |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function allProjects() |
150 | 150 | { |
151 | 151 | $wikiQuery = $this->client->createQueryBuilder(); |
152 | - $wikiQuery->select([ 'dbName', 'name', 'url' ])->from('wiki'); |
|
152 | + $wikiQuery->select(['dbName', 'name', 'url'])->from('wiki'); |
|
153 | 153 | $stmt = $wikiQuery->execute(); |
154 | 154 | $out = $stmt->fetchAll(); |
155 | 155 | return $out; |