Passed
Push — master ( 3c388a...58b85c )
by Sebastian
05:02
created
src/Request.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
      */
40 40
     protected static $instance;
41 41
     
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $baseURL = '';
46 46
     
47 47
     public function __construct()
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
         $this->init();
52 52
     }
53 53
     
54
-   /**
55
-    * Can be extended in a subclass, to avoid
56
-    * redefining the constructor.
57
-    */
54
+    /**
55
+     * Can be extended in a subclass, to avoid
56
+     * redefining the constructor.
57
+     */
58 58
     protected function init()
59 59
     {
60 60
         
@@ -126,30 +126,30 @@  discard block
 block discarded – undo
126 126
         return $this->buildURL($params, $dispatcher);
127 127
     }
128 128
     
129
-   /**
130
-    * Retrieves the name of the current dispatcher script / page.
131
-    * This is made to be extended and implemented in a subclass.
132
-    * 
133
-    * @return string
134
-    */
129
+    /**
130
+     * Retrieves the name of the current dispatcher script / page.
131
+     * This is made to be extended and implemented in a subclass.
132
+     * 
133
+     * @return string
134
+     */
135 135
     public function getDispatcher() : string
136 136
     {
137 137
         return '';
138 138
     }
139 139
     
140
-   /**
141
-    * Filters and retrieves the current request variables 
142
-    * to be used to build an URL to refresh the current page.
143
-    * 
144
-    * For further customization options, use the 
145
-    * {@see Request::createRefreshParams()} method.
146
-    * 
147
-    * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result.
148
-    * @param string[] $exclude Names of parameters to exclude from the result.
149
-    * @return array<string,mixed>
150
-    * 
151
-    * @see Request::createRefreshParams()
152
-    */
140
+    /**
141
+     * Filters and retrieves the current request variables 
142
+     * to be used to build an URL to refresh the current page.
143
+     * 
144
+     * For further customization options, use the 
145
+     * {@see Request::createRefreshParams()} method.
146
+     * 
147
+     * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result.
148
+     * @param string[] $exclude Names of parameters to exclude from the result.
149
+     * @return array<string,mixed>
150
+     * 
151
+     * @see Request::createRefreshParams()
152
+     */
153 153
     public function getRefreshParams(array $params = array(), array $exclude = array())
154 154
     {
155 155
         return $this->createRefreshParams()
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
         ->getParams();
159 159
     }
160 160
     
161
-   /**
162
-    * Creates an instance of the helper that can be used to
163
-    * retrieve the request's parameters collection, with the
164
-    * possiblity to exlude and override some by rules.
165
-    * 
166
-    * @return Request_RefreshParams
167
-    */
161
+    /**
162
+     * Creates an instance of the helper that can be used to
163
+     * retrieve the request's parameters collection, with the
164
+     * possiblity to exlude and override some by rules.
165
+     * 
166
+     * @return Request_RefreshParams
167
+     */
168 168
     public function createRefreshParams() : Request_RefreshParams
169 169
     {
170 170
         return new Request_RefreshParams();
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
         return $url;
198 198
     }
199 199
     
200
-   /**
201
-    * Retrieves the base URL of the application.
202
-    * @return string
203
-    */
200
+    /**
201
+     * Retrieves the base URL of the application.
202
+     * @return string
203
+     */
204 204
     public function getBaseURL() : string
205 205
     {
206 206
         return $this->baseURL;
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
         return $this->knownParams[$name];
231 231
     }
232 232
     
233
-   /**
234
-    * Retrieves a previously registered parameter instance.
235
-    * 
236
-    * @param string $name
237
-    * @throws Request_Exception
238
-    * @return Request_Param
239
-    */
233
+    /**
234
+     * Retrieves a previously registered parameter instance.
235
+     * 
236
+     * @param string $name
237
+     * @throws Request_Exception
238
+     * @return Request_Param
239
+     */
240 240
     public function getRegisteredParam(string $name) : Request_Param
241 241
     {
242 242
         if(isset($this->knownParams[$name])) {
@@ -253,48 +253,48 @@  discard block
 block discarded – undo
253 253
         );
254 254
     }
255 255
     
256
-   /**
257
-    * Checks whether a parameter with the specified name 
258
-    * has been registered.
259
-    * 
260
-    * @param string $name
261
-    * @return bool
262
-    */
256
+    /**
257
+     * Checks whether a parameter with the specified name 
258
+     * has been registered.
259
+     * 
260
+     * @param string $name
261
+     * @return bool
262
+     */
263 263
     public function hasRegisteredParam(string $name) : bool
264 264
     {
265 265
         return isset($this->knownParams[$name]);
266 266
     }
267 267
     
268
-   /**
269
-    * Retrieves an indexed array with accept mime types
270
-    * that the client sent, in the order of preference
271
-    * the client specified.
272
-    *
273
-    * Example:
274
-    *
275
-    * array(
276
-    *     'text/html',
277
-    *     'application/xhtml+xml',
278
-    *     'image/webp'
279
-    *     ...
280
-    * )
281
-    * 
282
-    * @return array
283
-    * @see Request::parseAcceptHeaders()
284
-    */
268
+    /**
269
+     * Retrieves an indexed array with accept mime types
270
+     * that the client sent, in the order of preference
271
+     * the client specified.
272
+     *
273
+     * Example:
274
+     *
275
+     * array(
276
+     *     'text/html',
277
+     *     'application/xhtml+xml',
278
+     *     'image/webp'
279
+     *     ...
280
+     * )
281
+     * 
282
+     * @return array
283
+     * @see Request::parseAcceptHeaders()
284
+     */
285 285
     public static function getAcceptHeaders() : array
286 286
     {
287 287
         return self::parseAcceptHeaders()->getMimeStrings();
288 288
     }
289 289
     
290
-   /**
291
-    * Returns an instance of the accept headers parser,
292
-    * to access information on the browser's accepted
293
-    * mime types.
294
-    *  
295
-    * @return Request_AcceptHeaders
296
-    * @see Request::getAcceptHeaders()
297
-    */
290
+    /**
291
+     * Returns an instance of the accept headers parser,
292
+     * to access information on the browser's accepted
293
+     * mime types.
294
+     *  
295
+     * @return Request_AcceptHeaders
296
+     * @see Request::getAcceptHeaders()
297
+     */
298 298
     public static function parseAcceptHeaders() : Request_AcceptHeaders
299 299
     {
300 300
         static $accept;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
         return false;
343 343
     }
344 344
     
345
-   /**
346
-    * Removes a single parameter from the request.
347
-    * If the parameter has been registered, also
348
-    * removes the registration info.
349
-    * 
350
-    * @param string $name
351
-    * @return Request
352
-    */
345
+    /**
346
+     * Removes a single parameter from the request.
347
+     * If the parameter has been registered, also
348
+     * removes the registration info.
349
+     * 
350
+     * @param string $name
351
+     * @return Request
352
+     */
353 353
     public function removeParam(string $name) : Request
354 354
     {
355 355
         if(isset($_REQUEST[$name])) {
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
         return $this;
364 364
     }
365 365
     
366
-   /**
367
-    * Removes several parameters from the request.
368
-    * 
369
-    * @param string[] $names
370
-    * @return Request
371
-    */
366
+    /**
367
+     * Removes several parameters from the request.
368
+     * 
369
+     * @param string[] $names
370
+     * @return Request
371
+     */
372 372
     public function removeParams(array $names) : Request
373 373
     {
374 374
         foreach($names as $name) {
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
         return $val;
436 436
     }
437 437
     
438
-   /**
439
-    * Treats the request parameter as a JSON string, and
440
-    * if it exists and contains valid JSON, returns the
441
-    * decoded JSON value as an array (default).
442
-    *
443
-    * @param string $name
444
-    * @param bool $assoc
445
-    * @return array|object
446
-    * 
447
-    * @see Request::getJSONAssoc()
448
-    * @see Request::getJSONObject()
449
-    */
438
+    /**
439
+     * Treats the request parameter as a JSON string, and
440
+     * if it exists and contains valid JSON, returns the
441
+     * decoded JSON value as an array (default).
442
+     *
443
+     * @param string $name
444
+     * @param bool $assoc
445
+     * @return array|object
446
+     * 
447
+     * @see Request::getJSONAssoc()
448
+     * @see Request::getJSONObject()
449
+     */
450 450
     public function getJSON(string $name, bool $assoc=true)
451 451
     {
452 452
         $value = $this->getParam($name);
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
         return new \stdClass();
472 472
     }
473 473
     
474
-   /**
475
-    * Like {@link Request::getJSON()}, but omitting the second
476
-    * parameter. Use this for more readable code.
477
-    * 
478
-    * @param string $name
479
-    * @return array
480
-    */
474
+    /**
475
+     * Like {@link Request::getJSON()}, but omitting the second
476
+     * parameter. Use this for more readable code.
477
+     * 
478
+     * @param string $name
479
+     * @return array
480
+     */
481 481
     public function getJSONAssoc(string $name) : array
482 482
     {
483 483
         $result = $this->getJSON($name);
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
         return array();
489 489
     }
490 490
     
491
-   /**
492
-    * Like {@link Request::getJSON()}, but omitting the second
493
-    * parameter. Use this for more readable code.
494
-    *
495
-    * @param string $name
496
-    * @return object
497
-    */
491
+    /**
492
+     * Like {@link Request::getJSON()}, but omitting the second
493
+     * parameter. Use this for more readable code.
494
+     *
495
+     * @param string $name
496
+     * @return object
497
+     */
498 498
     public function getJSONObject(string $name) : object
499 499
     {
500 500
         $result = $this->getJSON($name, false);
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
         return new \stdClass();
506 506
     }
507 507
     
508
-   /**
509
-    * Sends a JSON response with the correct headers.
510
-    *
511
-    * @param array|string $data
512
-    * @param bool $exit Whether to exit the script afterwards.
513
-    */
508
+    /**
509
+     * Sends a JSON response with the correct headers.
510
+     *
511
+     * @param array|string $data
512
+     * @param bool $exit Whether to exit the script afterwards.
513
+     */
514 514
     public static function sendJSON($data, bool $exit=true)
515 515
     {
516 516
         $payload = $data;
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
         }
531 531
     }
532 532
     
533
-   /**
534
-    * Sends HTML to the browser with the correct headers.
535
-    * 
536
-    * @param string $html
537
-    * @param bool $exit Whether to exit the script afterwards.
538
-    */
533
+    /**
534
+     * Sends HTML to the browser with the correct headers.
535
+     * 
536
+     * @param string $html
537
+     * @param bool $exit Whether to exit the script afterwards.
538
+     */
539 539
     public static function sendHTML(string $html, bool $exit=true)
540 540
     {
541 541
         header('Cache-Control: no-cache, must-revalidate');
@@ -550,16 +550,16 @@  discard block
 block discarded – undo
550 550
         }
551 551
     }
552 552
     
553
-   /**
554
-    * Creates a new instance of the URL comparer, which can check 
555
-    * whether the specified URLs match, regardless of the order in 
556
-    * which the query parameters are, if any.
557
-    * 
558
-    * @param string $sourceURL
559
-    * @param string $targetURL
560
-    * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
561
-    * @return Request_URLComparer
562
-    */
553
+    /**
554
+     * Creates a new instance of the URL comparer, which can check 
555
+     * whether the specified URLs match, regardless of the order in 
556
+     * which the query parameters are, if any.
557
+     * 
558
+     * @param string $sourceURL
559
+     * @param string $targetURL
560
+     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
561
+     * @return Request_URLComparer
562
+     */
563 563
     public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
564 564
     {
565 565
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
         return $comparer;
569 569
     }
570 570
     
571
-   /**
572
-    * Retrieves the full URL that was used to access the current page.
573
-    * @return string
574
-    */
571
+    /**
572
+     * Retrieves the full URL that was used to access the current page.
573
+     * @return string
574
+     */
575 575
     public function getCurrentURL() : string
576 576
     {
577 577
         return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
     public function getParam($name, $default = null)
91 91
     {
92 92
         $value = $default;
93
-        if(isset($_REQUEST[$name])) {
93
+        if (isset($_REQUEST[$name])) {
94 94
             $value = $_REQUEST[$name];
95 95
         }
96 96
         
97
-        if(isset($this->knownParams[$name])) {
97
+        if (isset($this->knownParams[$name])) {
98 98
             $value = $this->knownParams[$name]->validate($value);
99 99
         }
100 100
         
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
      * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed.
186 186
      * @return string
187 187
      */
188
-    public function buildURL($params = array(), string $dispatcher='')
188
+    public function buildURL($params = array(), string $dispatcher = '')
189 189
     {
190
-        $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher;
190
+        $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher;
191 191
         
192 192
         // append any leftover parameters to the end of the URL
193 193
         if (!empty($params)) {
194
-            $url .= '?' . http_build_query($params, '', '&amp;');
194
+            $url .= '?'.http_build_query($params, '', '&amp;');
195 195
         }
196 196
         
197 197
         return $url;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function registerParam($name)
224 224
     {
225
-        if(!isset($this->knownParams[$name])) {
225
+        if (!isset($this->knownParams[$name])) {
226 226
             $param = new Request_Param($this, $name);
227 227
             $this->knownParams[$name] = $param;
228 228
         }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     */
240 240
     public function getRegisteredParam(string $name) : Request_Param
241 241
     {
242
-        if(isset($this->knownParams[$name])) {
242
+        if (isset($this->knownParams[$name])) {
243 243
             return $this->knownParams[$name];
244 244
         }
245 245
         
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     {
300 300
         static $accept;
301 301
         
302
-        if(!isset($accept)) {
302
+        if (!isset($accept)) {
303 303
             $accept = new Request_AcceptHeaders();
304 304
         }
305 305
         
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     {
319 319
         $_REQUEST[$name] = $value;
320 320
         
321
-        if(isset($this->knownParams[$name])) {
321
+        if (isset($this->knownParams[$name])) {
322 322
             unset($this->knownParams[$name]);
323 323
         }
324 324
         
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
     */
353 353
     public function removeParam(string $name) : Request
354 354
     {
355
-        if(isset($_REQUEST[$name])) {
355
+        if (isset($_REQUEST[$name])) {
356 356
             unset($_REQUEST[$name]);
357 357
         }
358 358
         
359
-        if(isset($this->knownParams[$name])) {
359
+        if (isset($this->knownParams[$name])) {
360 360
             unset($this->knownParams[$name]);
361 361
         }
362 362
         
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     */
372 372
     public function removeParams(array $names) : Request
373 373
     {
374
-        foreach($names as $name) {
374
+        foreach ($names as $name) {
375 375
             $this->removeParam($name);
376 376
         }
377 377
         
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
      * @param string $name
388 388
      * @return bool
389 389
      */
390
-    public function getBool($name, $default=false)
390
+    public function getBool($name, $default = false)
391 391
     {
392 392
         $value = $this->getParam($name, $default);
393
-        if(ConvertHelper::isBoolean($value)) {
393
+        if (ConvertHelper::isBoolean($value)) {
394 394
             return ConvertHelper::string2bool($value);
395 395
         }
396 396
         
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     
400 400
     public function validate()
401 401
     {
402
-        foreach($this->knownParams as $param) 
402
+        foreach ($this->knownParams as $param) 
403 403
         {
404 404
             $name = $param->getName();
405 405
             
406
-            if($param->isRequired() && !$this->hasParam($name)) 
406
+            if ($param->isRequired() && !$this->hasParam($name)) 
407 407
             {
408 408
                 throw new Request_Exception(
409 409
                     'Missing request parameter '.$name,
@@ -425,10 +425,10 @@  discard block
 block discarded – undo
425 425
      * @param mixed $default
426 426
      * @return string
427 427
      */
428
-    public function getFilteredParam($name, $default=null)
428
+    public function getFilteredParam($name, $default = null)
429 429
     {
430 430
         $val = $this->getParam($name, $default);
431
-        if(is_string($val)) {
431
+        if (is_string($val)) {
432 432
             $val = htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8');
433 433
         }
434 434
         
@@ -447,24 +447,24 @@  discard block
 block discarded – undo
447 447
     * @see Request::getJSONAssoc()
448 448
     * @see Request::getJSONObject()
449 449
     */
450
-    public function getJSON(string $name, bool $assoc=true)
450
+    public function getJSON(string $name, bool $assoc = true)
451 451
     {
452 452
         $value = $this->getParam($name);
453 453
         
454
-        if(!empty($value) && is_string($value)) 
454
+        if (!empty($value) && is_string($value)) 
455 455
         {
456 456
             $data = json_decode($value, $assoc);
457 457
             
458
-            if($assoc && is_array($data)) {
458
+            if ($assoc && is_array($data)) {
459 459
                 return $data;
460 460
             }
461 461
             
462
-            if(is_object($data)) {
462
+            if (is_object($data)) {
463 463
                 return $data;
464 464
             }
465 465
         }
466 466
         
467
-        if($assoc) {
467
+        if ($assoc) {
468 468
             return array();
469 469
         }
470 470
         
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     public function getJSONAssoc(string $name) : array
482 482
     {
483 483
         $result = $this->getJSON($name);
484
-        if(is_array($result)) {
484
+        if (is_array($result)) {
485 485
             return $result;
486 486
         }
487 487
         
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     public function getJSONObject(string $name) : object
499 499
     {
500 500
         $result = $this->getJSON($name, false);
501
-        if(is_object($result)) {
501
+        if (is_object($result)) {
502 502
             return $result;
503 503
         }
504 504
         
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
     * @param array|string $data
512 512
     * @param bool $exit Whether to exit the script afterwards.
513 513
     */
514
-    public static function sendJSON($data, bool $exit=true)
514
+    public static function sendJSON($data, bool $exit = true)
515 515
     {
516 516
         $payload = $data;
517
-        if(!is_string($payload)) {
517
+        if (!is_string($payload)) {
518 518
             $payload = json_encode($payload);
519 519
         }
520 520
         
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
         
525 525
         echo $payload;
526 526
         
527
-        if($exit) 
527
+        if ($exit) 
528 528
         {
529 529
             exit;
530 530
         }
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
     * @param string $html
537 537
     * @param bool $exit Whether to exit the script afterwards.
538 538
     */
539
-    public static function sendHTML(string $html, bool $exit=true)
539
+    public static function sendHTML(string $html, bool $exit = true)
540 540
     {
541 541
         header('Cache-Control: no-cache, must-revalidate');
542 542
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         
545 545
         echo $html;
546 546
         
547
-        if($exit)
547
+        if ($exit)
548 548
         {
549 549
             exit;
550 550
         }
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
     * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present)
561 561
     * @return Request_URLComparer
562 562
     */
563
-    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer
563
+    public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer
564 564
     {
565 565
         $comparer = new Request_URLComparer($this, $sourceURL, $targetURL);
566 566
         $comparer->addLimitParams($limitParams);
Please login to merge, or discard this patch.
src/Request/RefreshParams/Exclude/Name.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@
 block discarded – undo
19 19
  */
20 20
 class Request_RefreshParams_Exclude_Name extends Request_RefreshParams_Exclude
21 21
 {
22
-   /**
23
-    * @var string
24
-    */
22
+    /**
23
+     * @var string
24
+     */
25 25
     private $name;
26 26
     
27 27
     public function __construct(string $paramName)
Please login to merge, or discard this patch.
src/Request/RefreshParams/Exclude/Callback.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
 {
23 23
     const ERROR_INVALID_CALLBACK = 62101;
24 24
     
25
-   /**
26
-    * @var callable
27
-    */
25
+    /**
26
+     * @var callable
27
+     */
28 28
     private $callback;
29 29
     
30 30
     public function __construct($callback)
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     
30 30
     public function __construct($callback)
31 31
     {
32
-        if(!is_callable($callback))
32
+        if (!is_callable($callback))
33 33
         {
34 34
             throw new Request_Exception(
35 35
                 'Invalid exclusion callback',
Please login to merge, or discard this patch.
src/Request/RefreshParams.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 {
24 24
     use Traits_Optionable;
25 25
     
26
-   /**
27
-    * @var array<string,mixed>
28
-    */
26
+    /**
27
+     * @var array<string,mixed>
28
+     */
29 29
     private $overrides = array();
30 30
     
31
-   /**
32
-    * @var Request_RefreshParams_Exclude[]
33
-    */
31
+    /**
32
+     * @var Request_RefreshParams_Exclude[]
33
+     */
34 34
     private $excludes = array();
35 35
     
36 36
     public function getDefaultOptions() : array
@@ -41,27 +41,27 @@  discard block
 block discarded – undo
41 41
         );
42 42
     }
43 43
     
44
-   /**
45
-    * Whether to automatically exclude the session variable
46
-    * from the parameters.
47
-    * 
48
-    * @param bool $exclude
49
-    * @return Request_RefreshParams
50
-    */
44
+    /**
45
+     * Whether to automatically exclude the session variable
46
+     * from the parameters.
47
+     * 
48
+     * @param bool $exclude
49
+     * @return Request_RefreshParams
50
+     */
51 51
     public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams
52 52
     {
53 53
         $this->setOption('exclude-session-name', $exclude);
54 54
         return $this;
55 55
     }
56 56
     
57
-   /**
58
-    * Whether to automatically exclude the HTML_QuickForm2
59
-    * request variable used to track whether a form has been
60
-    * submitted.
61
-    * 
62
-    * @param bool $exclude
63
-    * @return Request_RefreshParams
64
-    */
57
+    /**
58
+     * Whether to automatically exclude the HTML_QuickForm2
59
+     * request variable used to track whether a form has been
60
+     * submitted.
61
+     * 
62
+     * @param bool $exclude
63
+     * @return Request_RefreshParams
64
+     */
65 65
     public function setExcludeQuickform(bool $exclude) : Request_RefreshParams
66 66
     {
67 67
         $this->setOption('exclude-quickform-submitter', $exclude);
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
         return $this;
79 79
     }
80 80
     
81
-   /**
82
-    * Exclude a request using a callback function.
83
-    * 
84
-    * The function gets two parameters:
85
-    * 
86
-    * - The name of the request parameter
87
-    * - The value of the request parameter
88
-    * 
89
-    * If the callback returns a boolean true, the
90
-    * parameter will be excluded.
91
-    * 
92
-    * @param callable $callback
93
-    * @return Request_RefreshParams
94
-    */
81
+    /**
82
+     * Exclude a request using a callback function.
83
+     * 
84
+     * The function gets two parameters:
85
+     * 
86
+     * - The name of the request parameter
87
+     * - The value of the request parameter
88
+     * 
89
+     * If the callback returns a boolean true, the
90
+     * parameter will be excluded.
91
+     * 
92
+     * @param callable $callback
93
+     * @return Request_RefreshParams
94
+     */
95 95
     public function excludeParamByCallback($callback) : Request_RefreshParams
96 96
     {
97 97
         $this->excludes[] = new Request_RefreshParams_Exclude_Callback($callback);
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
         return $this;
100 100
     }
101 101
     
102
-   /**
103
-    * Excludes a request parameter by name.
104
-    * 
105
-    * @param array $paramNames
106
-    * @return Request_RefreshParams
107
-    */
102
+    /**
103
+     * Excludes a request parameter by name.
104
+     * 
105
+     * @param array $paramNames
106
+     * @return Request_RefreshParams
107
+     */
108 108
     public function excludeParamsByName(array $paramNames) : Request_RefreshParams
109 109
     {
110 110
         foreach($paramNames as $name)
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
         return $this;
116 116
     }
117 117
     
118
-   /**
119
-    * Overrides a parameter: even if it exists, this
120
-    * value will be used instead - even if it is on 
121
-    * the list of excluded parameters.
122
-    * 
123
-    * @param string $paramName
124
-    * @param mixed $paramValue
125
-    * @return Request_RefreshParams
126
-    */
118
+    /**
119
+     * Overrides a parameter: even if it exists, this
120
+     * value will be used instead - even if it is on 
121
+     * the list of excluded parameters.
122
+     * 
123
+     * @param string $paramName
124
+     * @param mixed $paramValue
125
+     * @return Request_RefreshParams
126
+     */
127 127
     public function overrideParam(string $paramName, $paramValue) : Request_RefreshParams
128 128
     {
129 129
         $this->overrides[$paramName] = $paramValue;
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
         return $this;
132 132
     }
133 133
     
134
-   /**
135
-    * Overrides an array of parameters. 
136
-    * 
137
-    * @param array $params
138
-    * @return Request_RefreshParams
139
-    */
134
+    /**
135
+     * Overrides an array of parameters. 
136
+     * 
137
+     * @param array $params
138
+     * @return Request_RefreshParams
139
+     */
140 140
     public function overrideParams(array $params) : Request_RefreshParams
141 141
     {
142 142
         foreach($params as $name => $value)
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
         return $this;
148 148
     }
149 149
     
150
-   /**
151
-    * Resolves all the parameter exclusions that should
152
-    * be applied to the list of parameters. This includes
153
-    * the manually added exclusions and the dynamic exclusions
154
-    * like the session name.
155
-    * 
156
-    * @return Request_RefreshParams_Exclude[]
157
-    */
150
+    /**
151
+     * Resolves all the parameter exclusions that should
152
+     * be applied to the list of parameters. This includes
153
+     * the manually added exclusions and the dynamic exclusions
154
+     * like the session name.
155
+     * 
156
+     * @return Request_RefreshParams_Exclude[]
157
+     */
158 158
     private function resolveExcludes() : array
159 159
     {
160 160
         $excludes = $this->excludes;
@@ -165,12 +165,12 @@  discard block
 block discarded – undo
165 165
         return $excludes;
166 166
     }
167 167
     
168
-   /**
169
-    * Automatically excludes the session name from the
170
-    * parameters, if present.
171
-    * 
172
-    * @param Request_RefreshParams_Exclude[] $excludes
173
-    */
168
+    /**
169
+     * Automatically excludes the session name from the
170
+     * parameters, if present.
171
+     * 
172
+     * @param Request_RefreshParams_Exclude[] $excludes
173
+     */
174 174
     private function autoExcludeSessionName(array &$excludes) : void
175 175
     {
176 176
         if($this->getBoolOption('exclude-session-name'))
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
         }
180 180
     }
181 181
    
182
-   /**
183
-    * Automatically excludes the HTML_QuickForm2 submit
184
-    * tracking variable, when enabled.
185
-    * 
186
-    * @param Request_RefreshParams_Exclude[] $excludes
187
-    */
182
+    /**
183
+     * Automatically excludes the HTML_QuickForm2 submit
184
+     * tracking variable, when enabled.
185
+     * 
186
+     * @param Request_RefreshParams_Exclude[] $excludes
187
+     */
188 188
     private function autoExcludeQuickform(array &$excludes) : void
189 189
     {
190 190
         if($this->getBoolOption('exclude-quickform-submitter'))
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
         }
197 197
     }
198 198
     
199
-   /**
200
-    * Retrieves the list of parameters matching the 
201
-    * current settings.
202
-    * 
203
-    * @return array<string,mixed>
204
-    */
199
+    /**
200
+     * Retrieves the list of parameters matching the 
201
+     * current settings.
202
+     * 
203
+     * @return array<string,mixed>
204
+     */
205 205
     public function getParams() : array
206 206
     {
207 207
         $params = $this->removeExcluded($_REQUEST);
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
         return $params;
218 218
     }
219 219
     
220
-   /**
221
-    * Removes all excluded parameters from the array.
222
-    * 
223
-    * @param array<string,mixed> $params
224
-    * @return array<string,mixed>
225
-    */
220
+    /**
221
+     * Removes all excluded parameters from the array.
222
+     * 
223
+     * @param array<string,mixed> $params
224
+     * @return array<string,mixed>
225
+     */
226 226
     private function removeExcluded(array $params) : array
227 227
     {
228 228
         $result = array();
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
         return $result;
241 241
     }
242 242
     
243
-   /**
244
-    * Checks all configured exclusions to see if the 
245
-    * parameter should be excluded or not.
246
-    * 
247
-    * @param string $paramName
248
-    * @param mixed $paramValue
249
-    * @return bool
250
-    */
243
+    /**
244
+     * Checks all configured exclusions to see if the 
245
+     * parameter should be excluded or not.
246
+     * 
247
+     * @param string $paramName
248
+     * @param mixed $paramValue
249
+     * @return bool
250
+     */
251 251
     public function isExcluded(string $paramName, $paramValue) : bool
252 252
     {
253 253
         $excludes = $this->resolveExcludes();
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     * @param bool $exclude
49 49
     * @return Request_RefreshParams
50 50
     */
51
-    public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams
51
+    public function setExcludeSessionName(bool $exclude = true) : Request_RefreshParams
52 52
     {
53 53
         $this->setOption('exclude-session-name', $exclude);
54 54
         return $this;
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     
71 71
     public function excludeParamByName(string $paramName) : Request_RefreshParams
72 72
     {
73
-        if($paramName !== '')
73
+        if ($paramName !== '')
74 74
         {
75 75
             $this->excludes[] = new Request_RefreshParams_Exclude_Name($paramName);
76 76
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
     */
108 108
     public function excludeParamsByName(array $paramNames) : Request_RefreshParams
109 109
     {
110
-        foreach($paramNames as $name)
110
+        foreach ($paramNames as $name)
111 111
         {
112 112
             $this->excludeParamByName((string)$name);
113 113
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     */
140 140
     public function overrideParams(array $params) : Request_RefreshParams
141 141
     {
142
-        foreach($params as $name => $value)
142
+        foreach ($params as $name => $value)
143 143
         {
144 144
             $this->overrideParam((string)$name, $value);
145 145
         }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     */
174 174
     private function autoExcludeSessionName(array &$excludes) : void
175 175
     {
176
-        if($this->getBoolOption('exclude-session-name'))
176
+        if ($this->getBoolOption('exclude-session-name'))
177 177
         {
178 178
             $excludes[] = new Request_RefreshParams_Exclude_Name(session_name());
179 179
         }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     */
188 188
     private function autoExcludeQuickform(array &$excludes) : void
189 189
     {
190
-        if($this->getBoolOption('exclude-quickform-submitter'))
190
+        if ($this->getBoolOption('exclude-quickform-submitter'))
191 191
         {
192 192
             $excludes[] = new Request_RefreshParams_Exclude_Callback(function(string $paramName)
193 193
             {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         // Note: using this loop instead of array_merge,
210 210
         // because array_merge has weird behavior when
211 211
         // using numeric keys.
212
-        foreach($this->overrides as $name => $val)
212
+        foreach ($this->overrides as $name => $val)
213 213
         {
214 214
             $params[$name] = $val;
215 215
         }
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $result = array();
229 229
         
230
-        foreach($params as $name => $value)
230
+        foreach ($params as $name => $value)
231 231
         {
232 232
             $name = (string)$name;
233 233
             
234
-            if(!$this->isExcluded($name, $value))
234
+            if (!$this->isExcluded($name, $value))
235 235
             {
236 236
                 $result[$name] = $value;
237 237
             }
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
     {
253 253
         $excludes = $this->resolveExcludes();
254 254
         
255
-        foreach($excludes as $exclude)
255
+        foreach ($excludes as $exclude)
256 256
         {
257
-            if($exclude->isExcluded($paramName, $paramValue))
257
+            if ($exclude->isExcluded($paramName, $paramValue))
258 258
             {
259 259
                 return true;
260 260
             }
Please login to merge, or discard this patch.