Mercurial > hg > cmmr2012-drupal-site
diff vendor/zendframework/zend-diactoros/src/Response.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | 5311817fb629 |
children |
line wrap: on
line diff
--- a/vendor/zendframework/zend-diactoros/src/Response.php Thu Feb 28 11:14:44 2019 +0000 +++ b/vendor/zendframework/zend-diactoros/src/Response.php Thu Feb 28 13:11:55 2019 +0000 @@ -1,7 +1,7 @@ <?php /** * @see https://github.com/zendframework/zend-diactoros for the canonical source repository - * @copyright Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2015-2018 Zend Technologies USA Inc. (http://www.zend.com) * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License */ @@ -113,7 +113,7 @@ /** * @var string */ - private $reasonPhrase = ''; + private $reasonPhrase; /** * @var int @@ -146,12 +146,6 @@ */ public function getReasonPhrase() { - if (! $this->reasonPhrase - && isset($this->phrases[$this->statusCode]) - ) { - $this->reasonPhrase = $this->phrases[$this->statusCode]; - } - return $this->reasonPhrase; } @@ -161,8 +155,7 @@ public function withStatus($code, $reasonPhrase = '') { $new = clone $this; - $new->setStatusCode($code); - $new->reasonPhrase = $reasonPhrase; + $new->setStatusCode($code, $reasonPhrase); return $new; } @@ -170,9 +163,10 @@ * Set a valid status code. * * @param int $code + * @param string $reasonPhrase * @throws InvalidArgumentException on an invalid status code. */ - private function setStatusCode($code) + private function setStatusCode($code, $reasonPhrase = '') { if (! is_numeric($code) || is_float($code) @@ -181,11 +175,24 @@ ) { throw new InvalidArgumentException(sprintf( 'Invalid status code "%s"; must be an integer between %d and %d, inclusive', - (is_scalar($code) ? $code : gettype($code)), + is_scalar($code) ? $code : gettype($code), static::MIN_STATUS_CODE_VALUE, static::MAX_STATUS_CODE_VALUE )); } - $this->statusCode = $code; + + if (! is_string($reasonPhrase)) { + throw new InvalidArgumentException(sprintf( + 'Unsupported response reason phrase; must be a string, received %s', + is_object($reasonPhrase) ? get_class($reasonPhrase) : gettype($reasonPhrase) + )); + } + + if ($reasonPhrase === '' && isset($this->phrases[$code])) { + $reasonPhrase = $this->phrases[$code]; + } + + $this->reasonPhrase = $reasonPhrase; + $this->statusCode = (int) $code; } }