Completed
Push — master ( c2c212...38c104 )
by Sam
03:48
created
web/app_dev.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
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.');
Please login to merge, or discard this patch.
xtools_utilities/nonautomated_edits_parse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
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");
Please login to merge, or discard this patch.
src/AppBundle/Helper/PageviewsHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/AppBundle/Twig/Extension.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/AppBundle/Controller/AdminStatsController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,7 @@
 block discarded – undo
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.
Please login to merge, or discard this patch.
src/AppBundle/Controller/QuoteController.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
4 4
 
5 5
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6 6
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
-use Symfony\Component\Debug\Exception\ContextErrorException;
8 7
 use Symfony\Component\Routing\Exception\InvalidParameterException;
9 8
 use Symfony\Component\HttpFoundation\Request;
10 9
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             'quote/all.html.twig',
112 112
             [
113 113
                 'base_dir' => realpath(
114
-                    $this->getParameter('kernel.root_dir') . '/..'
114
+                    $this->getParameter('kernel.root_dir').'/..'
115 115
                 ),
116 116
                 'xtPage' => 'bash',
117 117
                 'quotes' => $quotes,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
             'quote/view.html.twig',
161 161
             [
162 162
                 'base_dir' => realpath(
163
-                    $this->getParameter('kernel.root_dir') . '/..'
163
+                    $this->getParameter('kernel.root_dir').'/..'
164 164
                 ),
165 165
                 "xtPage" => "bash",
166 166
                 "text" => $text,
Please login to merge, or discard this patch.
src/Xtools/Project.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -14,6 +14,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace Xtools;
4 4
 
5 5
 use Mediawiki\Api\MediawikiApi;
6
-use Symfony\Component\VarDumper\VarDumper;
7 6
 
8 7
 /**
9 8
  * A Project is a single wiki that Xtools is querying.
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function getUrl($withTrailingSlash = true)
81 81
     {
82
-        return rtrim($this->getMetadata()['url'], '/') . ($withTrailingSlash ? '/' : '');
82
+        return rtrim($this->getMetadata()['url'], '/').($withTrailingSlash ? '/' : '');
83 83
     }
84 84
 
85 85
     /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         $metadata = $this->getRepository()->getMetadata($this->getUrl());
137 137
         return isset($metadata['general']['script'])
138 138
             ? $metadata['general']['script']
139
-            : $this->getScriptPath() . '/index.php';
139
+            : $this->getScriptPath().'/index.php';
140 140
     }
141 141
 
142 142
     /**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function getApiUrl()
148 148
     {
149
-        return rtrim($this->getUrl(), '/') . $this->getRepository()->getApiPath();
149
+        return rtrim($this->getUrl(), '/').$this->getRepository()->getApiPath();
150 150
     }
151 151
 
152 152
     /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function userOptInPage(User $user)
180 180
     {
181
-        $localPageName = 'User:' . $user->getUsername() . '/EditCounterOptIn.js';
181
+        $localPageName = 'User:'.$user->getUsername().'/EditCounterOptIn.js';
182 182
         return $localPageName;
183 183
     }
184 184
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         }
208 208
 
209 209
         // 3. Lastly, see if they've opted in globally on the default project or Meta.
210
-        $globalPageName = $user->getUsername() . '/EditCounterGlobalOptIn.js';
210
+        $globalPageName = $user->getUsername().'/EditCounterGlobalOptIn.js';
211 211
         $globalProject = $this->getRepository()->getGlobalProject();
212 212
         if ($globalProject instanceof Project) {
213 213
             $globalExists = $globalProject->getRepository()
Please login to merge, or discard this patch.
src/AppBundle/Twig/WikiExtension.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'>&rarr;</a>" .
287
+            $sectionWikitext = "<a target='_blank' href='$projectUrl/wiki/$title#$sectionTitleLink'>&rarr;</a>".
288 288
                 "<em class='text-muted'>$sectionTitle:</em> ";
289 289
             $wikitext = str_replace($sectionMatch[0][0], $sectionWikitext, $wikitext);
290 290
         }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -80,7 +80,6 @@  discard block
 block discarded – undo
80 80
 
81 81
     /**
82 82
      * Link to list of users who are in the given user group
83
-     * @param  string $username   Username
84 83
      * @param  string $projectUrl Project domain and protocol such as https://en.wikipedia.org
85 84
      * @param  string [$label]    The link text, defaults to $username
86 85
      * @return string Markup
@@ -230,7 +229,7 @@  discard block
 block discarded – undo
230 229
     /**
231 230
      * Get links to pageviews tools for the given page
232 231
      * @param  string $title      Title of page
233
-     * @param  string $projectUrl Project domain such as en.wikipedia.org
232
+     * @param  string $project Project domain such as en.wikipedia.org
234 233
      * @return string Markup
235 234
      */
236 235
     public function pageviewsLinks($title, $project)
Please login to merge, or discard this patch.
src/AppBundle/Helper/ApiHelper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
             throw new Exception("Unable to find project '$projectName'");
67 67
         }
68 68
 
69
-        $cacheKey = "siteinfo." . $project->getDatabaseName();
69
+        $cacheKey = "siteinfo.".$project->getDatabaseName();
70 70
         if ($this->cacheHas($cacheKey)) {
71 71
             return $this->cacheGet($cacheKey);
72 72
         }
73 73
 
74
-        $params = [ 'meta'=>'siteinfo', 'siprop'=>'general|namespaces' ];
74
+        $params = ['meta'=>'siteinfo', 'siprop'=>'general|namespaces'];
75 75
         $query = new SimpleRequest('query', $params);
76 76
 
77 77
         $result = [
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     public function groups($project, $username)
136 136
     {
137 137
         $this->setUp($project);
138
-        $params = [ "list"=>"users", "ususers"=>$username, "usprop"=>"groups" ];
138
+        $params = ["list"=>"users", "ususers"=>$username, "usprop"=>"groups"];
139 139
         $query = new SimpleRequest('query', $params);
140 140
         $result = [];
141 141
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     public function globalGroups($project, $username)
155 155
     {
156 156
         $this->setUp($project);
157
-        $params = [ "meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups" ];
157
+        $params = ["meta"=>"globaluserinfo", "guiuser"=>$username, "guiprop"=>"groups"];
158 158
         $query = new SimpleRequest('query', $params);
159 159
         $result = [];
160 160
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                 $groups[] = "B";
203 203
             }
204 204
             if (in_array("steward", $admin["groups"])) {
205
-                $groups[] = "S" ;
205
+                $groups[] = "S";
206 206
             }
207 207
             if (in_array("checkuser", $admin["groups"])) {
208 208
                 $groups[] = "CU";
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
             if (in_array("bot", $admin["groups"])) {
214 214
                 $groups[] = "Bot";
215 215
             }
216
-            $result[ $admin["name"] ] = [
216
+            $result[$admin["name"]] = [
217 217
                 "groups" => implode('/', $groups)
218 218
             ];
219 219
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             $normalized = [];
289 289
             if (isset($result['query']['normalized'])) {
290 290
                 array_map(
291
-                    function ($e) use (&$normalized) {
291
+                    function($e) use (&$normalized) {
292 292
                         $normalized[$e['to']] = $e['from'];
293 293
                     },
294 294
                     $result['query']['normalized']
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         ];
335 335
 
336 336
         // get assessments for this page from the API
337
-        $assessments = $this->massApi($params, $project, function ($data) {
337
+        $assessments = $this->massApi($params, $project, function($data) {
338 338
             return isset($data['pages'][0]['pageassessments']) ? $data['pages'][0]['pageassessments'] : [];
339 339
         }, 'pacontinue')['pages'];
340 340
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 $classAttrs = $config['class']['Unknown'];
359 359
                 $assessment['class']['value'] = '???';
360 360
                 $assessment['class']['category'] = $classAttrs['category'];
361
-                $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/". $classAttrs['badge'];
361
+                $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".$classAttrs['badge'];
362 362
             } else {
363 363
                 $classAttrs = $config['class'][$classValue];
364 364
                 $assessment['class'] = [
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
                 // add full URL to badge icon
371 371
                 if ($classAttrs['badge'] !== '') {
372
-                    $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/" .
372
+                    $assessment['class']['badge'] = "https://upload.wikimedia.org/wikipedia/commons/".
373 373
                         $classAttrs['badge'];
374 374
                 }
375 375
 
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
         $config = $this->getAssessmentsConfig();
419 419
 
420 420
         if (isset($config[$project]['class'][$class])) {
421
-            return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class'][$class]['badge'];
421
+            return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class'][$class]['badge'];
422 422
         } elseif (isset($config[$project]['class']['Unknown'])) {
423
-            return "https://upload.wikimedia.org/wikipedia/commons/" . $config[$project]['class']['Unknown']['badge'];
423
+            return "https://upload.wikimedia.org/wikipedia/commons/".$config[$project]['class']['Unknown']['badge'];
424 424
         } else {
425 425
             return "";
426 426
         }
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         $query = FluentRequest::factory()->setAction('query')->setParams($requestData);
514 514
         $innerPromise = $this->api->getRequestAsync($query);
515 515
 
516
-        $innerPromise->then(function ($result) use (&$data) {
516
+        $innerPromise->then(function($result) use (&$data) {
517 517
             // some failures come back as 200s, so we still resolve and let the outer function handle it
518 518
             if (isset($result['error']) || !isset($result['query'])) {
519 519
                 return $data['promise']->resolve($data);
Please login to merge, or discard this patch.