@@ -90,11 +90,11 @@ discard block |
||
| 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 |
||
| 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, '', '&'); |
|
| 194 | + $url .= '?'.http_build_query($params, '', '&'); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return $url; |
@@ -222,7 +222,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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); |
@@ -29,7 +29,7 @@ |
||
| 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', |
@@ -48,7 +48,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | * @param bool $enabled |
| 124 | 124 | * @return URLInfo |
| 125 | 125 | */ |
| 126 | - public function setUTFEncoding(bool $enabled=true) : URLInfo |
|
| 126 | + public function setUTFEncoding(bool $enabled = true) : URLInfo |
|
| 127 | 127 | { |
| 128 | - if($this->encodeUTFChars !== $enabled) |
|
| 128 | + if ($this->encodeUTFChars !== $enabled) |
|
| 129 | 129 | { |
| 130 | 130 | $this->encodeUTFChars = $enabled; |
| 131 | 131 | $this->parse(); // re-parse the URL to apply the changes |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | $port = $this->getInfoKey('port'); |
| 231 | 231 | |
| 232 | - if(!empty($port)) { |
|
| 232 | + if (!empty($port)) { |
|
| 233 | 233 | return (int)$port; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | protected function getInfoKey(string $name) : string |
| 311 | 311 | { |
| 312 | - if(isset($this->info[$name])) { |
|
| 312 | + if (isset($this->info[$name])) { |
|
| 313 | 313 | return (string)$this->info[$name]; |
| 314 | 314 | } |
| 315 | 315 | |
@@ -338,13 +338,13 @@ discard block |
||
| 338 | 338 | return $this->normalize(false); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - protected function normalize(bool $auth=true) : string |
|
| 341 | + protected function normalize(bool $auth = true) : string |
|
| 342 | 342 | { |
| 343 | - if(!$this->isValid()) { |
|
| 343 | + if (!$this->isValid()) { |
|
| 344 | 344 | return ''; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if(!isset($this->normalizer)) { |
|
| 347 | + if (!isset($this->normalizer)) { |
|
| 348 | 348 | $this->normalizer = new URLInfo_Normalizer($this); |
| 349 | 349 | } |
| 350 | 350 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function getHighlighted() : string |
| 376 | 376 | { |
| 377 | - if(!$this->isValid()) { |
|
| 377 | + if (!$this->isValid()) { |
|
| 378 | 378 | return ''; |
| 379 | 379 | } |
| 380 | 380 | |
@@ -416,14 +416,14 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | public function getParams() : array |
| 418 | 418 | { |
| 419 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 419 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 420 | 420 | return $this->info['params']; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $keep = array(); |
| 424 | - foreach($this->info['params'] as $name => $value) |
|
| 424 | + foreach ($this->info['params'] as $name => $value) |
|
| 425 | 425 | { |
| 426 | - if(!isset($this->excludedParams[$name])) { |
|
| 426 | + if (!isset($this->excludedParams[$name])) { |
|
| 427 | 427 | $keep[$name] = $value; |
| 428 | 428 | } |
| 429 | 429 | } |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | */ |
| 450 | 450 | public function getParam(string $name) : string |
| 451 | 451 | { |
| 452 | - if(isset($this->info['params'][$name])) { |
|
| 452 | + if (isset($this->info['params'][$name])) { |
|
| 453 | 453 | return $this->info['params'][$name]; |
| 454 | 454 | } |
| 455 | 455 | |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | public function excludeParam(string $name, string $reason) : URLInfo |
| 470 | 470 | { |
| 471 | - if(!isset($this->excludedParams[$name])) |
|
| 471 | + if (!isset($this->excludedParams[$name])) |
|
| 472 | 472 | { |
| 473 | 473 | $this->excludedParams[$name] = $reason; |
| 474 | 474 | $this->setParamExclusion(); |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | |
| 495 | 495 | public function getTypeLabel() : string |
| 496 | 496 | { |
| 497 | - if(!isset(self::$typeLabels)) |
|
| 497 | + if (!isset(self::$typeLabels)) |
|
| 498 | 498 | { |
| 499 | 499 | self::$typeLabels = array( |
| 500 | 500 | self::TYPE_EMAIL => t('Email'), |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | |
| 507 | 507 | $type = $this->getType(); |
| 508 | 508 | |
| 509 | - if(!isset(self::$typeLabels[$type])) |
|
| 509 | + if (!isset(self::$typeLabels[$type])) |
|
| 510 | 510 | { |
| 511 | 511 | throw new BaseException( |
| 512 | 512 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * @param bool $highlight |
| 527 | 527 | * @return URLInfo |
| 528 | 528 | */ |
| 529 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
| 529 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
| 530 | 530 | { |
| 531 | 531 | $this->highlightExcluded = $highlight; |
| 532 | 532 | return $this; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * @see URLInfo::isParamExclusionEnabled() |
| 575 | 575 | * @see URLInfo::setHighlightExcluded() |
| 576 | 576 | */ |
| 577 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
| 577 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
| 578 | 578 | { |
| 579 | 579 | $this->paramExclusion = $enabled; |
| 580 | 580 | return $this; |
@@ -600,13 +600,13 @@ discard block |
||
| 600 | 600 | */ |
| 601 | 601 | public function containsExcludedParams() : bool |
| 602 | 602 | { |
| 603 | - if(empty($this->excludedParams)) { |
|
| 603 | + if (empty($this->excludedParams)) { |
|
| 604 | 604 | return false; |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | $names = array_keys($this->info['params']); |
| 608 | - foreach($names as $name) { |
|
| 609 | - if(isset($this->excludedParams[$name])) { |
|
| 608 | + foreach ($names as $name) { |
|
| 609 | + if (isset($this->excludedParams[$name])) { |
|
| 610 | 610 | return true; |
| 611 | 611 | } |
| 612 | 612 | } |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | |
| 623 | 623 | public function offsetSet($offset, $value) |
| 624 | 624 | { |
| 625 | - if(in_array($offset, $this->infoKeys)) { |
|
| 625 | + if (in_array($offset, $this->infoKeys)) { |
|
| 626 | 626 | $this->info[$offset] = $value; |
| 627 | 627 | } |
| 628 | 628 | } |
@@ -639,11 +639,11 @@ discard block |
||
| 639 | 639 | |
| 640 | 640 | public function offsetGet($offset) |
| 641 | 641 | { |
| 642 | - if($offset === 'port') { |
|
| 642 | + if ($offset === 'port') { |
|
| 643 | 643 | return $this->getPort(); |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - if(in_array($offset, $this->infoKeys)) { |
|
| 646 | + if (in_array($offset, $this->infoKeys)) { |
|
| 647 | 647 | return $this->getInfoKey($offset); |
| 648 | 648 | } |
| 649 | 649 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * @return bool |
| 676 | 676 | * @throws BaseException |
| 677 | 677 | */ |
| 678 | - public function tryConnect(bool $verifySSL=true) : bool |
|
| 678 | + public function tryConnect(bool $verifySSL = true) : bool |
|
| 679 | 679 | { |
| 680 | 680 | return $this->createConnectionTester() |
| 681 | 681 | ->setVerifySSL($verifySSL) |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | */ |
| 719 | 719 | public function removeParam(string $param) : URLInfo |
| 720 | 720 | { |
| 721 | - if(isset($this->info['params'][$param])) |
|
| 721 | + if (isset($this->info['params'][$param])) |
|
| 722 | 722 | { |
| 723 | 723 | unset($this->info['params'][$param]); |
| 724 | 724 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | $output = curl_exec($ch); |
| 243 | 243 | |
| 244 | - if(isset($this->logfilePointer)) |
|
| 244 | + if (isset($this->logfilePointer)) |
|
| 245 | 245 | { |
| 246 | 246 | fclose($this->logfilePointer); |
| 247 | 247 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | // CURL will complain about an empty response when the |
| 254 | 254 | // server sends a 100-continue code. That should not be |
| 255 | 255 | // regarded as an error. |
| 256 | - if($output === false && $this->response->getCode() !== 100) |
|
| 256 | + if ($output === false && $this->response->getCode() !== 100) |
|
| 257 | 257 | { |
| 258 | 258 | $curlCode = curl_errno($ch); |
| 259 | 259 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | $ch = curl_init(); |
| 291 | 291 | |
| 292 | - if(!is_resource($ch)) |
|
| 292 | + if (!is_resource($ch)) |
|
| 293 | 293 | { |
| 294 | 294 | throw new RequestHelper_Exception( |
| 295 | 295 | 'Could not initialize a new cURL instance.', |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength()); |
| 302 | - $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary); |
|
| 302 | + $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary); |
|
| 303 | 303 | |
| 304 | 304 | curl_setopt($ch, CURLOPT_POST, true); |
| 305 | 305 | curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth()); |
@@ -312,18 +312,18 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | $loggingEnabled = $this->configureLogging($ch); |
| 314 | 314 | |
| 315 | - if(!$loggingEnabled) |
|
| 315 | + if (!$loggingEnabled) |
|
| 316 | 316 | { |
| 317 | 317 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if($this->verifySSL) |
|
| 320 | + if ($this->verifySSL) |
|
| 321 | 321 | { |
| 322 | 322 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 323 | 323 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if($url->hasUsername()) |
|
| 326 | + if ($url->hasUsername()) |
|
| 327 | 327 | { |
| 328 | 328 | curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername()); |
| 329 | 329 | curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword()); |
@@ -338,14 +338,14 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | protected function configureLogging($ch) : bool |
| 340 | 340 | { |
| 341 | - if(empty($this->logfile)) |
|
| 341 | + if (empty($this->logfile)) |
|
| 342 | 342 | { |
| 343 | 343 | return false; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | $res = fopen($this->logfile, 'w+'); |
| 347 | 347 | |
| 348 | - if($res === false) |
|
| 348 | + if ($res === false) |
|
| 349 | 349 | { |
| 350 | 350 | throw new RequestHelper_Exception( |
| 351 | 351 | 'Cannot open logfile for writing.', |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | |
| 376 | 376 | $this->setHeader('Expect', ''); |
| 377 | 377 | |
| 378 | - foreach($this->headers as $name => $value) { |
|
| 378 | + foreach ($this->headers as $name => $value) { |
|
| 379 | 379 | $result[] = $name.': '.$value; |
| 380 | 380 | } |
| 381 | 381 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | { |
| 393 | 393 | $response = $this->getResponse(); |
| 394 | 394 | |
| 395 | - if($response !== null) { |
|
| 395 | + if ($response !== null) { |
|
| 396 | 396 | return $response->getHeaders(); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | */ |
| 429 | 429 | public function getHeader(string $name) : string |
| 430 | 430 | { |
| 431 | - if(isset($this->headers[$name])) |
|
| 431 | + if (isset($this->headers[$name])) |
|
| 432 | 432 | { |
| 433 | 433 | return $this->headers[$name]; |
| 434 | 434 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | if (!empty($text)) { |
| 245 | 245 | $fragment = $this->dom->createDocumentFragment(); |
| 246 | - if(!@$fragment->appendXML($text)) { |
|
| 246 | + if (!@$fragment->appendXML($text)) { |
|
| 247 | 247 | throw new XMLHelper_Exception( |
| 248 | 248 | 'Cannot append XML fragment', |
| 249 | 249 | sprintf( |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param array<string,mixed> $attributes |
| 286 | 286 | * @return DOMNode |
| 287 | 287 | */ |
| 288 | - public function createRoot(string $name, array $attributes=array()) |
|
| 288 | + public function createRoot(string $name, array $attributes = array()) |
|
| 289 | 289 | { |
| 290 | 290 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
| 291 | 291 | $this->addAttributes($root, $attributes); |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | $string = str_replace('<', 'LT_ESCAPE', $string); |
| 312 | 312 | $string = str_replace('>', 'GT_ESCAPE', $string); |
| 313 | 313 | |
| 314 | - $string = str_replace(' ',' ', $string); |
|
| 315 | - $string = str_replace('&','&', $string); |
|
| 314 | + $string = str_replace(' ', ' ', $string); |
|
| 315 | + $string = str_replace('&', '&', $string); |
|
| 316 | 316 | |
| 317 | 317 | return $string; |
| 318 | 318 | } |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
| 333 | 333 | { |
| 334 | - if(!headers_sent() && !self::$simulation) |
|
| 334 | + if (!headers_sent() && !self::$simulation) |
|
| 335 | 335 | { |
| 336 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 336 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | echo $xml; |
@@ -347,12 +347,12 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public static function displayXML(string $xml) : void |
| 349 | 349 | { |
| 350 | - if(!headers_sent() && !self::$simulation) |
|
| 350 | + if (!headers_sent() && !self::$simulation) |
|
| 351 | 351 | { |
| 352 | 352 | header('Content-Type:text/xml; charset=utf-8'); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if(self::$simulation) |
|
| 355 | + if (self::$simulation) |
|
| 356 | 356 | { |
| 357 | 357 | $xml = '<pre>'.htmlspecialchars($xml).'</pre>'; |
| 358 | 358 | } |
@@ -370,16 +370,16 @@ discard block |
||
| 370 | 370 | * @param array<string,string> $customInfo Associative array with name => value pairs for custom tags to add to the output xml |
| 371 | 371 | * @see buildErrorXML() |
| 372 | 372 | */ |
| 373 | - public static function displayErrorXML($code, string $message, string $title, array $customInfo=array()) |
|
| 373 | + public static function displayErrorXML($code, string $message, string $title, array $customInfo = array()) |
|
| 374 | 374 | { |
| 375 | - if(!headers_sent() && !self::$simulation) { |
|
| 376 | - header('HTTP/1.1 400 Bad Request: ' . $title, true, 400); |
|
| 375 | + if (!headers_sent() && !self::$simulation) { |
|
| 376 | + header('HTTP/1.1 400 Bad Request: '.$title, true, 400); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo)); |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - public static function setSimulation(bool $simulate=true) : void |
|
| 382 | + public static function setSimulation(bool $simulate = true) : void |
|
| 383 | 383 | { |
| 384 | 384 | self::$simulation = $simulate; |
| 385 | 385 | } |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | * @param array<string,string> $customInfo |
| 429 | 429 | * @return string |
| 430 | 430 | */ |
| 431 | - public static function buildErrorXML($code, string $message, string $title, array $customInfo=array()) |
|
| 431 | + public static function buildErrorXML($code, string $message, string $title, array $customInfo = array()) |
|
| 432 | 432 | { |
| 433 | 433 | $xml = new DOMDocument('1.0', 'UTF-8'); |
| 434 | 434 | $xml->formatOutput = true; |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | $helper->addTextTag($root, 'title', $title); |
| 443 | 443 | $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']); |
| 444 | 444 | |
| 445 | - foreach($customInfo as $name => $value) { |
|
| 445 | + foreach ($customInfo as $name => $value) { |
|
| 446 | 446 | $helper->addTextTag($root, $name, $value); |
| 447 | 447 | } |
| 448 | 448 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public static function json($subject) : string |
| 110 | 110 | { |
| 111 | - if(!is_string($subject)) |
|
| 111 | + if (!is_string($subject)) |
|
| 112 | 112 | { |
| 113 | 113 | $subject = json_encode($subject, JSON_PRETTY_PRINT); |
| 114 | 114 | } |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @param bool $formatSource Whether to format the source with indentation to make it readable. |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - public static function xml(string $xml, bool $formatSource=false) : string |
|
| 128 | + public static function xml(string $xml, bool $formatSource = false) : string |
|
| 129 | 129 | { |
| 130 | - if($formatSource) |
|
| 130 | + if ($formatSource) |
|
| 131 | 131 | { |
| 132 | 132 | $dom = new DOMDocument(); |
| 133 | 133 | $dom->preserveWhiteSpace = false; |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | * @param bool $formatSource |
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | - public static function html(string $html, bool $formatSource=false) : string |
|
| 151 | + public static function html(string $html, bool $formatSource = false) : string |
|
| 152 | 152 | { |
| 153 | - if($formatSource) |
|
| 153 | + if ($formatSource) |
|
| 154 | 154 | { |
| 155 | 155 | $dom = new DOMDocument(); |
| 156 | 156 | $dom->preserveWhiteSpace = false; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | private function initUnits() : void |
| 50 | 50 | { |
| 51 | - if(isset(self::$units)) |
|
| 51 | + if (isset(self::$units)) |
|
| 52 | 52 | { |
| 53 | 53 | return; |
| 54 | 54 | } |
@@ -90,12 +90,12 @@ discard block |
||
| 90 | 90 | public function toString() : string |
| 91 | 91 | { |
| 92 | 92 | // specifically handle zero |
| 93 | - if($this->seconds <= 0) |
|
| 93 | + if ($this->seconds <= 0) |
|
| 94 | 94 | { |
| 95 | - return '0 ' . t('seconds'); |
|
| 95 | + return '0 '.t('seconds'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if($this->seconds < 1) |
|
| 98 | + if ($this->seconds < 1) |
|
| 99 | 99 | { |
| 100 | 100 | return t('less than a second'); |
| 101 | 101 | } |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | $last = array_pop($tokens); |
| 106 | 106 | |
| 107 | - if(empty($tokens)) |
|
| 107 | + if (empty($tokens)) |
|
| 108 | 108 | { |
| 109 | 109 | return $last; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
| 112 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | $seconds = $this->seconds; |
| 123 | 123 | $tokens = array(); |
| 124 | 124 | |
| 125 | - foreach(self::$units as $def) |
|
| 125 | + foreach (self::$units as $def) |
|
| 126 | 126 | { |
| 127 | 127 | $unitValue = intval($seconds / $def['value']); |
| 128 | 128 | |
| 129 | - if($unitValue <= 0) |
|
| 129 | + if ($unitValue <= 0) |
|
| 130 | 130 | { |
| 131 | 131 | continue; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $item = strval($unitValue) . ' '; |
|
| 134 | + $item = strval($unitValue).' '; |
|
| 135 | 135 | |
| 136 | - if(abs($unitValue) > 1) |
|
| 136 | + if (abs($unitValue) > 1) |
|
| 137 | 137 | { |
| 138 | 138 | $item .= $def['plural']; |
| 139 | 139 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'fragment' |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - foreach($parts as $part) |
|
| 80 | + foreach ($parts as $part) |
|
| 81 | 81 | { |
| 82 | 82 | $method = 'render_'.$part; |
| 83 | 83 | $result[] = (string)$this->$method(); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | protected function render_scheme() : string |
| 90 | 90 | { |
| 91 | - if(!$this->info->hasScheme()) { |
|
| 91 | + if (!$this->info->hasScheme()) { |
|
| 92 | 92 | return ''; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | protected function render_username() : string |
| 105 | 105 | { |
| 106 | - if(!$this->info->hasUsername()) { |
|
| 106 | + if (!$this->info->hasUsername()) { |
|
| 107 | 107 | return ''; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | protected function render_host() : string |
| 121 | 121 | { |
| 122 | - if(!$this->info->hasHost()) { |
|
| 122 | + if (!$this->info->hasHost()) { |
|
| 123 | 123 | return ''; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | protected function render_port() : string |
| 133 | 133 | { |
| 134 | - if(!$this->info->hasPort()) { |
|
| 134 | + if (!$this->info->hasPort()) { |
|
| 135 | 135 | return ''; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | protected function render_path() : string |
| 146 | 146 | { |
| 147 | - if(!$this->info->hasPath()) { |
|
| 147 | + if (!$this->info->hasPath()) { |
|
| 148 | 148 | return ''; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $previous = $this->info->isParamExclusionEnabled(); |
| 171 | 171 | |
| 172 | - if($previous) |
|
| 172 | + if ($previous) |
|
| 173 | 173 | { |
| 174 | 174 | $this->info->setParamExclusion(false); |
| 175 | 175 | } |
@@ -185,19 +185,19 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $params = $this->resolveParams(); |
| 187 | 187 | |
| 188 | - if(empty($params)) { |
|
| 188 | + if (empty($params)) { |
|
| 189 | 189 | return ''; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $tokens = array(); |
| 193 | 193 | $excluded = array(); |
| 194 | 194 | |
| 195 | - if($this->info->isParamExclusionEnabled()) |
|
| 195 | + if ($this->info->isParamExclusionEnabled()) |
|
| 196 | 196 | { |
| 197 | 197 | $excluded = $this->info->getExcludedParams(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - foreach($params as $param => $value) |
|
| 200 | + foreach ($params as $param => $value) |
|
| 201 | 201 | { |
| 202 | 202 | // If the parameter is numeric, it will automatically |
| 203 | 203 | // be an integer, so we need the conversion here. |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | $tag = $this->resolveTag($excluded, $param); |
| 220 | 220 | |
| 221 | - if(!empty($tag)) |
|
| 221 | + if (!empty($tag)) |
|
| 222 | 222 | { |
| 223 | 223 | $tokens[] = sprintf($tag, $parts); |
| 224 | 224 | } |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | protected function resolveTag(array $excluded, string $paramName) : string |
| 233 | 233 | { |
| 234 | 234 | // regular, non-excluded parameter |
| 235 | - if(!isset($excluded[$paramName])) |
|
| 235 | + if (!isset($excluded[$paramName])) |
|
| 236 | 236 | { |
| 237 | 237 | return '<span class="link-param">%s</span>'; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // highlight excluded parameters is disabled, ignore this parameter |
| 241 | - if(!$this->info->isHighlightExcludeEnabled()) |
|
| 241 | + if (!$this->info->isHighlightExcludeEnabled()) |
|
| 242 | 242 | { |
| 243 | 243 | return ''; |
| 244 | 244 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | protected function render_fragment() : string |
| 256 | 256 | { |
| 257 | - if(!$this->info->hasFragment()) { |
|
| 257 | + if (!$this->info->hasFragment()) { |
|
| 258 | 258 | return ''; |
| 259 | 259 | } |
| 260 | 260 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | $cssFolder = realpath(__DIR__.'/../../css'); |
| 271 | 271 | |
| 272 | - if($cssFolder === false) { |
|
| 272 | + if ($cssFolder === false) { |
|
| 273 | 273 | throw new BaseException( |
| 274 | 274 | 'Cannot find package CSS folder.', |
| 275 | 275 | null, |