@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $pathString = AbstractPathInfo::type2string($path); |
31 | 31 | |
32 | - if(!isset(self::$infoCache[$pathString])) |
|
32 | + if (!isset(self::$infoCache[$pathString])) |
|
33 | 33 | { |
34 | 34 | self::$infoCache[$pathString] = new FolderInfo($pathString); |
35 | 35 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | { |
59 | 59 | parent::__construct($path); |
60 | 60 | |
61 | - if(!self::is_dir($this->path)) |
|
61 | + if (!self::is_dir($this->path)) |
|
62 | 62 | { |
63 | 63 | throw new FileHelper_Exception( |
64 | 64 | 'Not a folder', |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | { |
81 | 81 | $path = trim($path); |
82 | 82 | |
83 | - if($path === '' || $path === '.' || $path === '..') |
|
83 | + if ($path === '' || $path === '.' || $path === '..') |
|
84 | 84 | { |
85 | 85 | return false; |
86 | 86 | } |
87 | 87 | |
88 | - if(is_dir($path)) |
|
88 | + if (is_dir($path)) |
|
89 | 89 | { |
90 | 90 | return true; |
91 | 91 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function delete() : FolderInfo |
105 | 105 | { |
106 | - if(!$this->exists()) |
|
106 | + if (!$this->exists()) |
|
107 | 107 | { |
108 | 108 | return $this; |
109 | 109 | } |
110 | 110 | |
111 | - if(rmdir($this->path)) |
|
111 | + if (rmdir($this->path)) |
|
112 | 112 | { |
113 | 113 | return $this; |
114 | 114 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function create() : FolderInfo |
136 | 136 | { |
137 | - if(is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path)) |
|
137 | + if (is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path)) |
|
138 | 138 | { |
139 | 139 | return $this; |
140 | 140 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $path = realpath($this->path); |
96 | 96 | |
97 | - if($path !== false) |
|
97 | + if ($path !== false) |
|
98 | 98 | { |
99 | 99 | return FileHelper::normalizePath($path); |
100 | 100 | } |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | * @return $this |
114 | 114 | * @throws FileHelper_Exception |
115 | 115 | */ |
116 | - private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode=null) : self |
|
116 | + private function requireTrue(bool $condition, string $conditionLabel, ?int $errorCode = null) : self |
|
117 | 117 | { |
118 | - if($condition === true) |
|
118 | + if ($condition === true) |
|
119 | 119 | { |
120 | 120 | return $this; |
121 | 121 | } |
122 | 122 | |
123 | - if($errorCode === null) |
|
123 | + if ($errorCode === null) |
|
124 | 124 | { |
125 | 125 | $errorCode = FileHelper::ERROR_FILE_DOES_NOT_EXIST; |
126 | 126 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @return $this |
138 | 138 | * @throws FileHelper_Exception |
139 | 139 | */ |
140 | - public function requireExists(?int $errorCode=null) : self |
|
140 | + public function requireExists(?int $errorCode = null) : self |
|
141 | 141 | { |
142 | 142 | return $this->requireTrue( |
143 | 143 | !empty($this->path) && realpath($this->path) !== false, |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return $this |
152 | 152 | * @throws FileHelper_Exception |
153 | 153 | */ |
154 | - public function requireReadable(?int $errorCode=null) : self |
|
154 | + public function requireReadable(?int $errorCode = null) : self |
|
155 | 155 | { |
156 | 156 | $this->requireExists($errorCode); |
157 | 157 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @return $this |
168 | 168 | * @throws FileHelper_Exception |
169 | 169 | */ |
170 | - public function requireWritable(?int $errorCode=null) : self |
|
170 | + public function requireWritable(?int $errorCode = null) : self |
|
171 | 171 | { |
172 | 172 | return $this->requireTrue( |
173 | 173 | $this->isWritable(), |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function requireIsFile() : FileInfo |
186 | 186 | { |
187 | - if($this instanceof FileInfo) |
|
187 | + if ($this instanceof FileInfo) |
|
188 | 188 | { |
189 | 189 | return $this; |
190 | 190 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function requireIsFolder() : FolderInfo |
209 | 209 | { |
210 | - if($this instanceof FolderInfo) |
|
210 | + if ($this instanceof FolderInfo) |
|
211 | 211 | { |
212 | 212 | return $this; |
213 | 213 | } |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public static function type2string($path) : string |
230 | 230 | { |
231 | - if($path instanceof PathInfoInterface) |
|
231 | + if ($path instanceof PathInfoInterface) |
|
232 | 232 | { |
233 | 233 | return $path->getPath(); |
234 | 234 | } |
235 | 235 | |
236 | - if($path instanceof DirectoryIterator) |
|
236 | + if ($path instanceof DirectoryIterator) |
|
237 | 237 | { |
238 | 238 | return $path->getPathname(); |
239 | 239 | } |
@@ -255,19 +255,19 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public static function resolveType($path) : PathInfoInterface |
257 | 257 | { |
258 | - if($path instanceof PathInfoInterface) |
|
258 | + if ($path instanceof PathInfoInterface) |
|
259 | 259 | { |
260 | 260 | return $path; |
261 | 261 | } |
262 | 262 | |
263 | 263 | $path = self::type2string($path); |
264 | 264 | |
265 | - if(FolderInfo::is_dir($path)) |
|
265 | + if (FolderInfo::is_dir($path)) |
|
266 | 266 | { |
267 | 267 | return FolderInfo::factory($path); |
268 | 268 | } |
269 | 269 | |
270 | - if(FileInfo::is_file($path)) |
|
270 | + if (FileInfo::is_file($path)) |
|
271 | 271 | { |
272 | 272 | return FileInfo::factory($path); |
273 | 273 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return $this |
125 | 125 | * @throws Request_Exception |
126 | 126 | */ |
127 | - public function setCallback(callable $callback, array $args=array()) : self |
|
127 | + public function setCallback(callable $callback, array $args = array()) : self |
|
128 | 128 | { |
129 | 129 | return $this->setValidation( |
130 | 130 | self::VALIDATION_TYPE_CALLBACK, |
@@ -149,22 +149,22 @@ discard block |
||
149 | 149 | // first off, apply filtering |
150 | 150 | $value = $this->filter($value); |
151 | 151 | |
152 | - if($this->valueType === self::VALUE_TYPE_LIST) |
|
152 | + if ($this->valueType === self::VALUE_TYPE_LIST) |
|
153 | 153 | { |
154 | - if(!is_array($value)) |
|
154 | + if (!is_array($value)) |
|
155 | 155 | { |
156 | 156 | $value = explode(',', $value); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $keep = array(); |
160 | 160 | |
161 | - foreach($value as $subval) |
|
161 | + foreach ($value as $subval) |
|
162 | 162 | { |
163 | 163 | $subval = $this->filter($subval); |
164 | 164 | |
165 | 165 | $subval = $this->applyValidations($subval, true); |
166 | 166 | |
167 | - if($subval !== null) { |
|
167 | + if ($subval !== null) { |
|
168 | 168 | $keep[] = $subval; |
169 | 169 | } |
170 | 170 | } |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param mixed $value |
184 | 184 | * @return mixed |
185 | 185 | */ |
186 | - protected function applyValidations($value, bool $subval=false) |
|
186 | + protected function applyValidations($value, bool $subval = false) |
|
187 | 187 | { |
188 | 188 | // go through all enqueued validations in turn, each time |
189 | 189 | // replacing the value with the adjusted, validated value. |
190 | - foreach($this->validations as $validateDef) |
|
190 | + foreach ($this->validations as $validateDef) |
|
191 | 191 | { |
192 | 192 | $value = $this->validateType($value, $validateDef['type'], $validateDef['params'], $subval); |
193 | 193 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $class = Request_Param_Validator::class.'_'.ucfirst($type); |
212 | 212 | |
213 | - if(!class_exists($class)) |
|
213 | + if (!class_exists($class)) |
|
214 | 214 | { |
215 | 215 | throw new Request_Exception( |
216 | 216 | 'Unknown validation type.', |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | { |
362 | 362 | $args = func_get_args(); // cannot be used as function parameter in some PHP versions |
363 | 363 | |
364 | - if(is_array($args[0])) |
|
364 | + if (is_array($args[0])) |
|
365 | 365 | { |
366 | 366 | $args = $args[0]; |
367 | 367 | } |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | * @param mixed $default |
512 | 512 | * @return mixed |
513 | 513 | */ |
514 | - public function get($default=null) |
|
514 | + public function get($default = null) |
|
515 | 515 | { |
516 | 516 | $value = $this->request->getParam($this->paramName); |
517 | - if($value !== null && $value !== '') { |
|
517 | + if ($value !== null && $value !== '') { |
|
518 | 518 | return $value; |
519 | 519 | } |
520 | 520 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | { |
539 | 539 | foreach ($this->filters as $filter) |
540 | 540 | { |
541 | - $method = 'applyFilter_' . $filter['type']; |
|
541 | + $method = 'applyFilter_'.$filter['type']; |
|
542 | 542 | $value = $this->$method($value, $filter['params']); |
543 | 543 | } |
544 | 544 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | |
558 | 558 | $filter = new $class($this); |
559 | 559 | |
560 | - if($filter instanceof Request_Param_Filter) |
|
560 | + if ($filter instanceof Request_Param_Filter) |
|
561 | 561 | { |
562 | 562 | $filter->setOptions($config['params']); |
563 | 563 | return $filter->filter($value); |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @param bool $stripEmptyEntries Remove empty entries from the array? |
717 | 717 | * @return $this |
718 | 718 | */ |
719 | - public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self |
|
719 | + public function addCommaSeparatedFilter(bool $trimEntries = true, bool $stripEmptyEntries = true) : self |
|
720 | 720 | { |
721 | 721 | $this->setArray(); |
722 | 722 | |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @return $this |
736 | 736 | * @throws Request_Exception |
737 | 737 | */ |
738 | - protected function addClassFilter(string $name, array $params=array()) : self |
|
738 | + protected function addClassFilter(string $name, array $params = array()) : self |
|
739 | 739 | { |
740 | 740 | return $this->addFilter( |
741 | 741 | self::FILTER_TYPE_CLASS, |
@@ -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 |
@@ -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(); |
@@ -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); |