@@ -24,9 +24,9 @@ |
||
24 | 24 | { |
25 | 25 | use Traits_Optionable; |
26 | 26 | |
27 | - /** |
|
28 | - * @var RequestParam |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var RequestParam |
|
29 | + */ |
|
30 | 30 | protected $param; |
31 | 31 | |
32 | 32 | protected $value; |
@@ -29,14 +29,14 @@ |
||
29 | 29 | */ |
30 | 30 | protected $param; |
31 | 31 | |
32 | - /** |
|
33 | - * @var mixed |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var mixed |
|
34 | + */ |
|
35 | 35 | protected $value; |
36 | 36 | |
37 | - /** |
|
38 | - * @var bool |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var bool |
|
39 | + */ |
|
40 | 40 | protected $isSubvalue = false; |
41 | 41 | |
42 | 42 | public function __construct(RequestParam $param, bool $subval) |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | public function isHeadersPosition($position) |
172 | 172 | { |
173 | - if($this->headersPosition === $position) { |
|
173 | + if ($this->headersPosition === $position) { |
|
174 | 174 | return true; |
175 | 175 | } |
176 | 176 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | self::HEADERS_TOP |
198 | 198 | ); |
199 | 199 | |
200 | - if(!in_array($position, $validPositions)) { |
|
200 | + if (!in_array($position, $validPositions)) { |
|
201 | 201 | throw new CSVHelper_Exception( |
202 | 202 | 'Invalid headers position', |
203 | 203 | sprintf( |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function getRow($index) |
255 | 255 | { |
256 | - if(isset($this->data[$index])) { |
|
256 | + if (isset($this->data[$index])) { |
|
257 | 257 | return $this->data[$index]; |
258 | 258 | } |
259 | 259 | |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | public function getColumn($index) |
321 | 321 | { |
322 | 322 | $data = array(); |
323 | - for($i=0; $i < $this->rowCount; $i++) { |
|
323 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
324 | 324 | $value = ''; |
325 | - if(isset($this->data[$i][$index])) { |
|
325 | + if (isset($this->data[$i][$index])) { |
|
326 | 326 | $value = $this->data[$i][$index]; |
327 | 327 | } |
328 | 328 | |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function columnExists($index) |
341 | 341 | { |
342 | - if($index < $this->columnCount) { |
|
342 | + if ($index < $this->columnCount) { |
|
343 | 343 | return true; |
344 | 344 | } |
345 | 345 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | { |
351 | 351 | $this->reset(); |
352 | 352 | |
353 | - if(empty(trim($this->csv))) { |
|
353 | + if (empty(trim($this->csv))) { |
|
354 | 354 | $this->addError('Tried to parse an empty CSV string.'); |
355 | 355 | return; |
356 | 356 | } |
@@ -362,14 +362,14 @@ discard block |
||
362 | 362 | |
363 | 363 | $parser = self::createParser(); |
364 | 364 | |
365 | - if(!$parser->parse($this->csv)) { |
|
365 | + if (!$parser->parse($this->csv)) { |
|
366 | 366 | $this->addError('The CSV string could not be parsed.'); |
367 | 367 | return; |
368 | 368 | } |
369 | 369 | |
370 | 370 | $result = $parser->data; |
371 | 371 | |
372 | - switch($this->headersPosition) |
|
372 | + switch ($this->headersPosition) |
|
373 | 373 | { |
374 | 374 | case self::HEADERS_TOP: |
375 | 375 | $this->headers = array_shift($result); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | case self::HEADERS_LEFT: |
379 | 379 | $keep = array(); |
380 | 380 | $total = count($result); |
381 | - for($i=0; $i < $total; $i++) { |
|
381 | + for ($i = 0; $i < $total; $i++) { |
|
382 | 382 | $row = $result[$i]; |
383 | 383 | $this->headers[] = array_shift($row); |
384 | 384 | $keep[] = $row; |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | $this->data = $result; |
392 | 392 | $this->rowCount = count($this->data); |
393 | 393 | |
394 | - for($i=0; $i < $this->rowCount; $i++) { |
|
394 | + for ($i = 0; $i < $this->rowCount; $i++) { |
|
395 | 395 | $amount = count($this->data[$i]); |
396 | - if($amount > $this->columnCount) { |
|
396 | + if ($amount > $this->columnCount) { |
|
397 | 397 | $this->columnCount = $amount; |
398 | 398 | } |
399 | 399 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | ',,' => ',' |
438 | 438 | ); |
439 | 439 | |
440 | - foreach($search as $char => $separator) { |
|
441 | - if(strstr($this->csv, $char)) { |
|
440 | + foreach ($search as $char => $separator) { |
|
441 | + if (strstr($this->csv, $char)) { |
|
442 | 442 | return $separator; |
443 | 443 | } |
444 | 444 | } |
@@ -452,11 +452,11 @@ discard block |
||
452 | 452 | * @param string $delimiter |
453 | 453 | * @return Csv |
454 | 454 | */ |
455 | - public static function createParser(string $delimiter=self::DELIMITER_AUTO) : Csv |
|
455 | + public static function createParser(string $delimiter = self::DELIMITER_AUTO) : Csv |
|
456 | 456 | { |
457 | 457 | $csv = new Csv(); |
458 | 458 | |
459 | - if($delimiter !== self::DELIMITER_AUTO) { |
|
459 | + if ($delimiter !== self::DELIMITER_AUTO) { |
|
460 | 460 | $csv->delimiter = $delimiter; |
461 | 461 | } |
462 | 462 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | |
485 | 485 | $result = $parser->auto($path); |
486 | 486 | |
487 | - if(is_string($result)) { |
|
487 | + if (is_string($result)) { |
|
488 | 488 | return $parser->data; |
489 | 489 | } |
490 | 490 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $parser = self::createParser(); |
518 | 518 | $result = $parser->parse($string); |
519 | 519 | |
520 | - if($result === true) { |
|
520 | + if ($result === true) { |
|
521 | 521 | return $parser->data; |
522 | 522 | } |
523 | 523 |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | { |
26 | 26 | protected ?string $details = null; |
27 | 27 | |
28 | - /** |
|
29 | - * @param string $message |
|
30 | - * @param string|NULL $details |
|
31 | - * @param int|NULL $code |
|
32 | - * @param Throwable|NULL $previous |
|
33 | - */ |
|
28 | + /** |
|
29 | + * @param string $message |
|
30 | + * @param string|NULL $details |
|
31 | + * @param int|NULL $code |
|
32 | + * @param Throwable|NULL $previous |
|
33 | + */ |
|
34 | 34 | public function __construct(string $message, ?string $details=null, $code=null, $previous=null) |
35 | 35 | { |
36 | 36 | if(defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true') |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | if($code === null) |
42 | 42 | { |
43 | - $code = 0; |
|
43 | + $code = 0; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | parent::__construct($message, $code, $previous); |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | $this->details = $details; |
49 | 49 | } |
50 | 50 | |
51 | - /** |
|
52 | - * Retrieves the detailed error description, if any. |
|
53 | - * @return string |
|
54 | - */ |
|
51 | + /** |
|
52 | + * Retrieves the detailed error description, if any. |
|
53 | + * @return string |
|
54 | + */ |
|
55 | 55 | public function getDetails() : string |
56 | 56 | { |
57 | 57 | return $this->details ?? ''; |
58 | 58 | } |
59 | 59 | |
60 | - /** |
|
61 | - * Displays pertinent information on the exception. |
|
62 | - */ |
|
60 | + /** |
|
61 | + * Displays pertinent information on the exception. |
|
62 | + */ |
|
63 | 63 | public function display() : void |
64 | 64 | { |
65 | 65 | if(!headers_sent()) { |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | echo $this->getInfo(); |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Retrieves information on the exception that can be |
|
74 | - * easily accessed. |
|
75 | - * |
|
76 | - * @return ConvertHelper_ThrowableInfo |
|
77 | - */ |
|
72 | + /** |
|
73 | + * Retrieves information on the exception that can be |
|
74 | + * easily accessed. |
|
75 | + * |
|
76 | + * @return ConvertHelper_ThrowableInfo |
|
77 | + */ |
|
78 | 78 | public function getInfo() : ConvertHelper_ThrowableInfo |
79 | 79 | { |
80 | 80 | return ConvertHelper::throwable2info($this); |
81 | 81 | } |
82 | 82 | |
83 | - /** |
|
84 | - * Dumps a current PHP function trace, as a text only string. |
|
85 | - */ |
|
83 | + /** |
|
84 | + * Dumps a current PHP function trace, as a text only string. |
|
85 | + */ |
|
86 | 86 | public static function dumpTraceAsString() : void |
87 | 87 | { |
88 | 88 | try |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Dumps a current PHP function trace, with HTML styling. |
|
100 | - */ |
|
98 | + /** |
|
99 | + * Dumps a current PHP function trace, with HTML styling. |
|
100 | + */ |
|
101 | 101 | public static function dumpTraceAsHTML() : void |
102 | 102 | { |
103 | 103 | try |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Creates an exception info instance from a throwable instance. |
|
117 | - * |
|
118 | - * @param Throwable $e |
|
119 | - * @return ConvertHelper_ThrowableInfo |
|
120 | - * @see ConvertHelper::throwable2info() |
|
121 | - */ |
|
115 | + /** |
|
116 | + * Creates an exception info instance from a throwable instance. |
|
117 | + * |
|
118 | + * @param Throwable $e |
|
119 | + * @return ConvertHelper_ThrowableInfo |
|
120 | + * @see ConvertHelper::throwable2info() |
|
121 | + */ |
|
122 | 122 | public static function createInfo(Throwable $e) : ConvertHelper_ThrowableInfo |
123 | 123 | { |
124 | 124 | return ConvertHelper::throwable2info($e); |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | * @param int|NULL $code |
32 | 32 | * @param Throwable|NULL $previous |
33 | 33 | */ |
34 | - public function __construct(string $message, ?string $details=null, $code=null, $previous=null) |
|
34 | + public function __construct(string $message, ?string $details = null, $code = null, $previous = null) |
|
35 | 35 | { |
36 | - if(defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true') |
|
36 | + if (defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true') |
|
37 | 37 | { |
38 | 38 | $message .= PHP_EOL.$details; |
39 | 39 | } |
40 | 40 | |
41 | - if($code === null) |
|
41 | + if ($code === null) |
|
42 | 42 | { |
43 | 43 | $code = 0; |
44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function display() : void |
64 | 64 | { |
65 | - if(!headers_sent()) { |
|
65 | + if (!headers_sent()) { |
|
66 | 66 | header('Content-type:text/plain; charset=utf-8'); |
67 | 67 | } |
68 | 68 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | { |
90 | 90 | throw new BaseException(''); |
91 | 91 | } |
92 | - catch(BaseException $e) |
|
92 | + catch (BaseException $e) |
|
93 | 93 | { |
94 | 94 | echo self::createInfo($e)->toString(); |
95 | 95 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | throw new BaseException(''); |
106 | 106 | } |
107 | - catch(BaseException $e) |
|
107 | + catch (BaseException $e) |
|
108 | 108 | { |
109 | 109 | echo '<pre style="background:#fff;font-family:monospace;font-size:14px;color:#444;padding:16px;border:solid 1px #999;border-radius:4px;">'; |
110 | 110 | echo self::createInfo($e)->toString(); |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | $this->init(); |
57 | 57 | } |
58 | 58 | |
59 | - /** |
|
60 | - * Can be extended in a subclass, to avoid |
|
61 | - * redefining the constructor. |
|
62 | - * |
|
63 | - * @return void |
|
64 | - */ |
|
59 | + /** |
|
60 | + * Can be extended in a subclass, to avoid |
|
61 | + * redefining the constructor. |
|
62 | + * |
|
63 | + * @return void |
|
64 | + */ |
|
65 | 65 | protected function init() : void |
66 | 66 | { |
67 | 67 | |
@@ -126,30 +126,30 @@ discard block |
||
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 a 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 a 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()) : array |
154 | 154 | { |
155 | 155 | return $this->createRefreshParams() |
@@ -158,13 +158,13 @@ discard block |
||
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 | - * possibility to exclude 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 | + * possibility to exclude 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(); |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | return $url; |
201 | 201 | } |
202 | 202 | |
203 | - /** |
|
204 | - * Retrieves the base URL of the application. |
|
205 | - * @return string |
|
206 | - */ |
|
203 | + /** |
|
204 | + * Retrieves the base URL of the application. |
|
205 | + * @return string |
|
206 | + */ |
|
207 | 207 | public function getBaseURL() : string |
208 | 208 | { |
209 | 209 | return $this->baseURL; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | return $this->knownParams[$name]; |
234 | 234 | } |
235 | 235 | |
236 | - /** |
|
237 | - * Retrieves a previously registered parameter instance. |
|
238 | - * |
|
239 | - * @param string $name |
|
240 | - * @return RequestParam |
|
241 | - *@throws Request_Exception |
|
242 | - */ |
|
236 | + /** |
|
237 | + * Retrieves a previously registered parameter instance. |
|
238 | + * |
|
239 | + * @param string $name |
|
240 | + * @return RequestParam |
|
241 | + *@throws Request_Exception |
|
242 | + */ |
|
243 | 243 | public function getRegisteredParam(string $name) : RequestParam |
244 | 244 | { |
245 | 245 | if(isset($this->knownParams[$name])) { |
@@ -256,48 +256,48 @@ discard block |
||
256 | 256 | ); |
257 | 257 | } |
258 | 258 | |
259 | - /** |
|
260 | - * Checks whether a parameter with the specified name |
|
261 | - * has been registered. |
|
262 | - * |
|
263 | - * @param string $name |
|
264 | - * @return bool |
|
265 | - */ |
|
259 | + /** |
|
260 | + * Checks whether a parameter with the specified name |
|
261 | + * has been registered. |
|
262 | + * |
|
263 | + * @param string $name |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | 266 | public function hasRegisteredParam(string $name) : bool |
267 | 267 | { |
268 | 268 | return isset($this->knownParams[$name]); |
269 | 269 | } |
270 | 270 | |
271 | - /** |
|
272 | - * Retrieves an indexed array with accept mime types |
|
273 | - * that the client sent, in the order of preference |
|
274 | - * the client specified. |
|
275 | - * |
|
276 | - * Example: |
|
277 | - * |
|
278 | - * array( |
|
279 | - * 'text/html', |
|
280 | - * 'application/xhtml+xml', |
|
281 | - * 'image/webp' |
|
282 | - * ... |
|
283 | - * ) |
|
284 | - * |
|
285 | - * @return string[] |
|
286 | - * @see Request::parseAcceptHeaders() |
|
287 | - */ |
|
271 | + /** |
|
272 | + * Retrieves an indexed array with accept mime types |
|
273 | + * that the client sent, in the order of preference |
|
274 | + * the client specified. |
|
275 | + * |
|
276 | + * Example: |
|
277 | + * |
|
278 | + * array( |
|
279 | + * 'text/html', |
|
280 | + * 'application/xhtml+xml', |
|
281 | + * 'image/webp' |
|
282 | + * ... |
|
283 | + * ) |
|
284 | + * |
|
285 | + * @return string[] |
|
286 | + * @see Request::parseAcceptHeaders() |
|
287 | + */ |
|
288 | 288 | public static function getAcceptHeaders() : array |
289 | 289 | { |
290 | 290 | return self::parseAcceptHeaders()->getMimeStrings(); |
291 | 291 | } |
292 | 292 | |
293 | - /** |
|
294 | - * Returns an instance of the "accept" headers parser, |
|
295 | - * to access information on the browser's accepted |
|
296 | - * mime types. |
|
297 | - * |
|
298 | - * @return Request_AcceptHeaders |
|
299 | - * @see Request::getAcceptHeaders() |
|
300 | - */ |
|
293 | + /** |
|
294 | + * Returns an instance of the "accept" headers parser, |
|
295 | + * to access information on the browser's accepted |
|
296 | + * mime types. |
|
297 | + * |
|
298 | + * @return Request_AcceptHeaders |
|
299 | + * @see Request::getAcceptHeaders() |
|
300 | + */ |
|
301 | 301 | public static function parseAcceptHeaders() : Request_AcceptHeaders |
302 | 302 | { |
303 | 303 | static $accept; |
@@ -341,14 +341,14 @@ discard block |
||
341 | 341 | return $this->getParam($name) !== null; |
342 | 342 | } |
343 | 343 | |
344 | - /** |
|
345 | - * Removes a single parameter from the request. |
|
346 | - * If the parameter has been registered, also |
|
347 | - * removes the registration info. |
|
348 | - * |
|
349 | - * @param string $name |
|
350 | - * @return Request |
|
351 | - */ |
|
344 | + /** |
|
345 | + * Removes a single parameter from the request. |
|
346 | + * If the parameter has been registered, also |
|
347 | + * removes the registration info. |
|
348 | + * |
|
349 | + * @param string $name |
|
350 | + * @return Request |
|
351 | + */ |
|
352 | 352 | public function removeParam(string $name) : Request |
353 | 353 | { |
354 | 354 | if(isset($_REQUEST[$name])) { |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | return $this; |
363 | 363 | } |
364 | 364 | |
365 | - /** |
|
366 | - * Removes several parameters from the request. |
|
367 | - * |
|
368 | - * @param string[] $names |
|
369 | - * @return Request |
|
370 | - */ |
|
365 | + /** |
|
366 | + * Removes several parameters from the request. |
|
367 | + * |
|
368 | + * @param string[] $names |
|
369 | + * @return Request |
|
370 | + */ |
|
371 | 371 | public function removeParams(array $names) : Request |
372 | 372 | { |
373 | 373 | foreach($names as $name) { |
@@ -563,11 +563,11 @@ discard block |
||
563 | 563 | exit; |
564 | 564 | } |
565 | 565 | |
566 | - /** |
|
567 | - * Sends HTML to the browser with the correct headers. |
|
568 | - * |
|
569 | - * @param string $html |
|
570 | - */ |
|
566 | + /** |
|
567 | + * Sends HTML to the browser with the correct headers. |
|
568 | + * |
|
569 | + * @param string $html |
|
570 | + */ |
|
571 | 571 | public static function sendHTML(string $html) : void |
572 | 572 | { |
573 | 573 | header('Cache-Control: no-cache, must-revalidate'); |
@@ -588,16 +588,16 @@ discard block |
||
588 | 588 | exit; |
589 | 589 | } |
590 | 590 | |
591 | - /** |
|
592 | - * Creates a new instance of the URL comparer, which can check |
|
593 | - * whether the specified URLs match, regardless of the order in |
|
594 | - * which the query parameters are, if any. |
|
595 | - * |
|
596 | - * @param string $sourceURL |
|
597 | - * @param string $targetURL |
|
598 | - * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
599 | - * @return Request_URLComparer |
|
600 | - */ |
|
591 | + /** |
|
592 | + * Creates a new instance of the URL comparer, which can check |
|
593 | + * whether the specified URLs match, regardless of the order in |
|
594 | + * which the query parameters are, if any. |
|
595 | + * |
|
596 | + * @param string $sourceURL |
|
597 | + * @param string $targetURL |
|
598 | + * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
599 | + * @return Request_URLComparer |
|
600 | + */ |
|
601 | 601 | public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
602 | 602 | { |
603 | 603 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | return $comparer; |
607 | 607 | } |
608 | 608 | |
609 | - /** |
|
610 | - * Retrieves the full URL that was used to access the current page. |
|
611 | - * @return string |
|
612 | - */ |
|
609 | + /** |
|
610 | + * Retrieves the full URL that was used to access the current page. |
|
611 | + * @return string |
|
612 | + */ |
|
613 | 613 | public function getCurrentURL() : string |
614 | 614 | { |
615 | 615 | return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $value = $_REQUEST[$name] ?? $default; |
93 | 93 | |
94 | - if(isset($this->knownParams[$name])) { |
|
94 | + if (isset($this->knownParams[$name])) { |
|
95 | 95 | $value = $this->knownParams[$name]->validate($value); |
96 | 96 | } |
97 | 97 | |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | * @param string $dispatcher Relative path to script to use for the URL. Append trailing slash if needed. |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function buildURL(array $params = array(), string $dispatcher='') : string |
|
191 | + public function buildURL(array $params = array(), string $dispatcher = '') : string |
|
192 | 192 | { |
193 | - $url = rtrim($this->getBaseURL(), '/') . '/' . $dispatcher; |
|
193 | + $url = rtrim($this->getBaseURL(), '/').'/'.$dispatcher; |
|
194 | 194 | |
195 | 195 | // append any leftover parameters to the end of the URL |
196 | 196 | if (!empty($params)) { |
197 | - $url .= '?' . http_build_query($params, '', '&'); |
|
197 | + $url .= '?'.http_build_query($params, '', '&'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | return $url; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function registerParam(string $name) : RequestParam |
227 | 227 | { |
228 | - if(!isset($this->knownParams[$name])) { |
|
228 | + if (!isset($this->knownParams[$name])) { |
|
229 | 229 | $param = new RequestParam($this, $name); |
230 | 230 | $this->knownParams[$name] = $param; |
231 | 231 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function getRegisteredParam(string $name) : RequestParam |
244 | 244 | { |
245 | - if(isset($this->knownParams[$name])) { |
|
245 | + if (isset($this->knownParams[$name])) { |
|
246 | 246 | return $this->knownParams[$name]; |
247 | 247 | } |
248 | 248 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | { |
303 | 303 | static $accept; |
304 | 304 | |
305 | - if(!isset($accept)) { |
|
305 | + if (!isset($accept)) { |
|
306 | 306 | $accept = new Request_AcceptHeaders(); |
307 | 307 | } |
308 | 308 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | { |
322 | 322 | $_REQUEST[$name] = $value; |
323 | 323 | |
324 | - if(isset($this->knownParams[$name])) { |
|
324 | + if (isset($this->knownParams[$name])) { |
|
325 | 325 | unset($this->knownParams[$name]); |
326 | 326 | } |
327 | 327 | |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | */ |
352 | 352 | public function removeParam(string $name) : Request |
353 | 353 | { |
354 | - if(isset($_REQUEST[$name])) { |
|
354 | + if (isset($_REQUEST[$name])) { |
|
355 | 355 | unset($_REQUEST[$name]); |
356 | 356 | } |
357 | 357 | |
358 | - if(isset($this->knownParams[$name])) { |
|
358 | + if (isset($this->knownParams[$name])) { |
|
359 | 359 | unset($this->knownParams[$name]); |
360 | 360 | } |
361 | 361 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function removeParams(array $names) : Request |
372 | 372 | { |
373 | - foreach($names as $name) { |
|
373 | + foreach ($names as $name) { |
|
374 | 374 | $this->removeParam($name); |
375 | 375 | } |
376 | 376 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | * @return bool |
389 | 389 | * @throws ConvertHelper_Exception |
390 | 390 | */ |
391 | - public function getBool(string $name, bool $default=false) : bool |
|
391 | + public function getBool(string $name, bool $default = false) : bool |
|
392 | 392 | { |
393 | 393 | $value = $this->getParam($name, $default); |
394 | 394 | |
395 | - if(ConvertHelper::isBoolean($value)) { |
|
395 | + if (ConvertHelper::isBoolean($value)) { |
|
396 | 396 | return ConvertHelper::string2bool($value); |
397 | 397 | } |
398 | 398 | |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | |
402 | 402 | public function validate() : void |
403 | 403 | { |
404 | - foreach($this->knownParams as $param) |
|
404 | + foreach ($this->knownParams as $param) |
|
405 | 405 | { |
406 | 406 | $name = $param->getName(); |
407 | 407 | |
408 | - if($param->isRequired() && !$this->hasParam($name)) |
|
408 | + if ($param->isRequired() && !$this->hasParam($name)) |
|
409 | 409 | { |
410 | 410 | throw new Request_Exception( |
411 | 411 | 'Missing request parameter '.$name, |
@@ -427,26 +427,26 @@ discard block |
||
427 | 427 | * @param mixed $default |
428 | 428 | * @return mixed |
429 | 429 | */ |
430 | - public function getFilteredParam(string $name, $default=null) |
|
430 | + public function getFilteredParam(string $name, $default = null) |
|
431 | 431 | { |
432 | 432 | $val = $this->getParam($name, $default); |
433 | 433 | |
434 | - if(is_string($val)) |
|
434 | + if (is_string($val)) |
|
435 | 435 | { |
436 | 436 | return htmlspecialchars(trim(strip_tags($val)), ENT_QUOTES, 'UTF-8'); |
437 | 437 | } |
438 | 438 | |
439 | - if(is_bool($val)) |
|
439 | + if (is_bool($val)) |
|
440 | 440 | { |
441 | 441 | return ConvertHelper::boolStrict2string($val); |
442 | 442 | } |
443 | 443 | |
444 | - if(is_numeric($val)) |
|
444 | + if (is_numeric($val)) |
|
445 | 445 | { |
446 | 446 | return (string)$val; |
447 | 447 | } |
448 | 448 | |
449 | - if(is_null($val)) |
|
449 | + if (is_null($val)) |
|
450 | 450 | { |
451 | 451 | return ''; |
452 | 452 | } |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * @see Request::getJSONObject() |
467 | 467 | * @see Request::getJSONAssoc() |
468 | 468 | */ |
469 | - public function getJSON(string $name, bool $assoc=true) |
|
469 | + public function getJSON(string $name, bool $assoc = true) |
|
470 | 470 | { |
471 | 471 | $value = $this->getParam($name); |
472 | 472 | |
473 | - if(!empty($value) && is_string($value)) |
|
473 | + if (!empty($value) && is_string($value)) |
|
474 | 474 | { |
475 | 475 | try |
476 | 476 | { |
@@ -481,16 +481,16 @@ discard block |
||
481 | 481 | return array(); |
482 | 482 | } |
483 | 483 | |
484 | - if($assoc && is_array($data)) { |
|
484 | + if ($assoc && is_array($data)) { |
|
485 | 485 | return $data; |
486 | 486 | } |
487 | 487 | |
488 | - if(is_object($data)) { |
|
488 | + if (is_object($data)) { |
|
489 | 489 | return $data; |
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
493 | - if($assoc) { |
|
493 | + if ($assoc) { |
|
494 | 494 | return array(); |
495 | 495 | } |
496 | 496 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | public function getJSONAssoc(string $name) : array |
508 | 508 | { |
509 | 509 | $result = $this->getJSON($name); |
510 | - if(is_array($result)) { |
|
510 | + if (is_array($result)) { |
|
511 | 511 | return $result; |
512 | 512 | } |
513 | 513 | |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | public function getJSONObject(string $name) : object |
525 | 525 | { |
526 | 526 | $result = $this->getJSON($name, false); |
527 | - if(is_object($result)) { |
|
527 | + if (is_object($result)) { |
|
528 | 528 | return $result; |
529 | 529 | } |
530 | 530 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | { |
542 | 542 | $payload = $data; |
543 | 543 | |
544 | - if(!is_string($payload)) { |
|
544 | + if (!is_string($payload)) { |
|
545 | 545 | $payload = json_encode($payload, JSON_THROW_ON_ERROR); |
546 | 546 | } |
547 | 547 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present) |
599 | 599 | * @return Request_URLComparer |
600 | 600 | */ |
601 | - public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
|
601 | + public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams = array()) : Request_URLComparer |
|
602 | 602 | { |
603 | 603 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
604 | 604 | $comparer->addLimitParams($limitParams); |
@@ -475,8 +475,7 @@ |
||
475 | 475 | try |
476 | 476 | { |
477 | 477 | $data = json_decode($value, $assoc, 512, JSON_THROW_ON_ERROR); |
478 | - } |
|
479 | - catch (JsonException $e) |
|
478 | + } catch (JsonException $e) |
|
480 | 479 | { |
481 | 480 | return array(); |
482 | 481 | } |