diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 14:18:18 +0100 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:18:18 +0100 |
commit | e1b923ab7d9070631b9bcf24fe1c42678f827169 (patch) | |
tree | 402fc0be56a0000701d969697ba1f271a66b8413 /vendor/sabre/http/lib/Response.php | |
parent | bed9876d68ac72a27f3c05fa3ed5c4ccad39b72e (diff) | |
parent | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (diff) | |
download | volse-hubzilla-e1b923ab7d9070631b9bcf24fe1c42678f827169.tar.gz volse-hubzilla-e1b923ab7d9070631b9bcf24fe1c42678f827169.tar.bz2 volse-hubzilla-e1b923ab7d9070631b9bcf24fe1c42678f827169.zip |
Merge branch 'cherry-pick-6685381f' into 'dev'
another bulk of composer updates
See merge request hubzilla/core!1781
Diffstat (limited to 'vendor/sabre/http/lib/Response.php')
-rw-r--r-- | vendor/sabre/http/lib/Response.php | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/vendor/sabre/http/lib/Response.php b/vendor/sabre/http/lib/Response.php index 01920d8d9..64dfbc0b2 100644 --- a/vendor/sabre/http/lib/Response.php +++ b/vendor/sabre/http/lib/Response.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\HTTP; /** @@ -9,14 +11,14 @@ namespace Sabre\HTTP; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class Response extends Message implements ResponseInterface { - +class Response extends Message implements ResponseInterface +{ /** * This is the list of currently registered HTTP status codes. * * @var array */ - static $statusCodes = [ + public static $statusCodes = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', @@ -81,57 +83,55 @@ class Response extends Message implements ResponseInterface { ]; /** - * HTTP status code + * HTTP status code. * * @var int */ protected $status; /** - * HTTP status text + * HTTP status text. * * @var string */ protected $statusText; /** - * Creates the response object + * Creates the response object. * * @param string|int $status - * @param array $headers - * @param resource $body + * @param array $headers + * @param resource $body */ - function __construct($status = null, array $headers = null, $body = null) { - - if (!is_null($status)) $this->setStatus($status); - if (!is_null($headers)) $this->setHeaders($headers); - if (!is_null($body)) $this->setBody($body); - + public function __construct($status = 500, array $headers = null, $body = null) + { + if (null !== $status) { + $this->setStatus($status); + } + if (null !== $headers) { + $this->setHeaders($headers); + } + if (null !== $body) { + $this->setBody($body); + } } - /** * Returns the current HTTP status code. - * - * @return int */ - function getStatus() { - + public function getStatus(): int + { return $this->status; - } /** * Returns the human-readable status string. * * In the case of a 200, this may for example be 'OK'. - * - * @return string */ - function getStatusText() { - + public function getStatusText(): string + { return $this->statusText; - } /** @@ -144,21 +144,20 @@ class Response extends Message implements ResponseInterface { * added. * * @param string|int $status + * * @throws \InvalidArgumentException - * @return void */ - function setStatus($status) { - + public function setStatus($status) + { if (ctype_digit($status) || is_int($status)) { - $statusCode = $status; - $statusText = isset(self::$statusCodes[$status]) ? self::$statusCodes[$status] : 'Unknown'; - + $statusText = self::$statusCodes[$status] ?? 'Unknown'; } else { list( $statusCode, $statusText ) = explode(' ', $status, 2); + $statusCode = (int) $statusCode; } if ($statusCode < 100 || $statusCode > 999) { throw new \InvalidArgumentException('The HTTP status code must be exactly 3 digits'); @@ -166,28 +165,24 @@ class Response extends Message implements ResponseInterface { $this->status = $statusCode; $this->statusText = $statusText; - } /** * Serializes the response object as a string. * * This is useful for debugging purposes. - * - * @return string */ - function __toString() { - - $str = 'HTTP/' . $this->httpVersion . ' ' . $this->getStatus() . ' ' . $this->getStatusText() . "\r\n"; + public function __toString(): string + { + $str = 'HTTP/'.$this->httpVersion.' '.$this->getStatus().' '.$this->getStatusText()."\r\n"; foreach ($this->getHeaders() as $key => $value) { foreach ($value as $v) { - $str .= $key . ": " . $v . "\r\n"; + $str .= $key.': '.$v."\r\n"; } } $str .= "\r\n"; $str .= $this->getBodyAsString(); - return $str; + return $str; } - } |