From 580c3f4ffe9608d2beb56d418c68b3b112420e76 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Nov 2019 12:49:51 +0000 Subject: another bulk of composer updates (cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce) --- vendor/sabre/http/lib/Response.php | 75 ++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 40 deletions(-) (limited to 'vendor/sabre/http/lib/Response.php') 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 @@ '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; } - } -- cgit v1.2.3