Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -1,14 +1,13 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see https://github.com/zendframework/zend-http for the canonical source repository
* @copyright Copyright (c) 2005-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-http/blob/master/LICENSE.md New BSD License
*/
namespace Zend\Http;
use Zend\Http\Exception\RuntimeException;
use Zend\Stdlib\ErrorHandler;
use Zend\Stdlib\ResponseInterface;
@@ -35,6 +34,7 @@ class Response extends AbstractMessage implements ResponseInterface
const STATUS_CODE_206 = 206;
const STATUS_CODE_207 = 207;
const STATUS_CODE_208 = 208;
const STATUS_CODE_226 = 226;
const STATUS_CODE_300 = 300;
const STATUS_CODE_301 = 301;
const STATUS_CODE_302 = 302;
@@ -43,6 +43,7 @@ class Response extends AbstractMessage implements ResponseInterface
const STATUS_CODE_305 = 305;
const STATUS_CODE_306 = 306;
const STATUS_CODE_307 = 307;
const STATUS_CODE_308 = 308;
const STATUS_CODE_400 = 400;
const STATUS_CODE_401 = 401;
const STATUS_CODE_402 = 402;
@@ -70,6 +71,9 @@ class Response extends AbstractMessage implements ResponseInterface
const STATUS_CODE_428 = 428;
const STATUS_CODE_429 = 429;
const STATUS_CODE_431 = 431;
const STATUS_CODE_451 = 451;
const STATUS_CODE_444 = 444;
const STATUS_CODE_499 = 499;
const STATUS_CODE_500 = 500;
const STATUS_CODE_501 = 501;
const STATUS_CODE_502 = 502;
@@ -79,7 +83,9 @@ class Response extends AbstractMessage implements ResponseInterface
const STATUS_CODE_506 = 506;
const STATUS_CODE_507 = 507;
const STATUS_CODE_508 = 508;
const STATUS_CODE_510 = 510;
const STATUS_CODE_511 = 511;
const STATUS_CODE_599 = 599;
/**#@-*/
/**
@@ -100,6 +106,7 @@ class Response extends AbstractMessage implements ResponseInterface
206 => 'Partial Content',
207 => 'Multi-status',
208 => 'Already Reported',
226 => 'IM Used',
// REDIRECTION CODES
300 => 'Multiple Choices',
301 => 'Moved Permanently',
@@ -109,6 +116,7 @@ class Response extends AbstractMessage implements ResponseInterface
305 => 'Use Proxy',
306 => 'Switch Proxy', // Deprecated
307 => 'Temporary Redirect',
308 => 'Permanent Redirect',
// CLIENT ERROR
400 => 'Bad Request',
401 => 'Unauthorized',
@@ -137,6 +145,9 @@ class Response extends AbstractMessage implements ResponseInterface
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',
444 => 'Connection Closed Without Response',
451 => 'Unavailable For Legal Reasons',
499 => 'Client Closed Request',
// SERVER ERROR
500 => 'Internal Server Error',
501 => 'Not Implemented',
@@ -147,7 +158,9 @@ class Response extends AbstractMessage implements ResponseInterface
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
508 => 'Loop Detected',
510 => 'Not Extended',
511 => 'Network Authentication Required',
599 => 'Network Connect Timeout Error',
];
/**
@@ -158,7 +171,7 @@ class Response extends AbstractMessage implements ResponseInterface
/**
* @var string|null Null means it will be looked up from the $reasonPhrase list above
*/
protected $reasonPhrase = null;
protected $reasonPhrase;
/**
* Populate object from string
@@ -170,26 +183,24 @@ class Response extends AbstractMessage implements ResponseInterface
public static function fromString($string)
{
$lines = explode("\r\n", $string);
if (!is_array($lines) || count($lines) === 1) {
if (! is_array($lines) || count($lines) === 1) {
$lines = explode("\n", $string);
}
$firstLine = array_shift($lines);
$response = new static();
$response->parseStatusLine($firstLine);
$regex = '/^HTTP\/(?P<version>1\.[01]) (?P<status>\d{3})(?:[ ]+(?P<reason>.*))?$/';
$matches = [];
if (!preg_match($regex, $firstLine, $matches)) {
throw new Exception\InvalidArgumentException(
'A valid response status line was not found in the provided string'
);
/**
* @link https://tools.ietf.org/html/rfc7231#section-6.2.1
*/
if ($response->statusCode === static::STATUS_CODE_100) {
$next = array_shift($lines); // take next line
$next = empty($next) ? array_shift($lines) : $next; // take next or skip if empty
$response->parseStatusLine($next);
}
$response->version = $matches['version'];
$response->setStatusCode($matches['status']);
$response->setReasonPhrase((isset($matches['reason']) ? $matches['reason'] : ''));
if (count($lines) === 0) {
return $response;
}
@@ -231,6 +242,26 @@ class Response extends AbstractMessage implements ResponseInterface
return $response;
}
/**
* @param string $line
* @throws Exception\InvalidArgumentException
* @throws Exception\RuntimeException
*/
protected function parseStatusLine($line)
{
$regex = '/^HTTP\/(?P<version>1\.[01]) (?P<status>\d{3})(?:[ ]+(?P<reason>.*))?$/';
$matches = [];
if (! preg_match($regex, $line, $matches)) {
throw new Exception\InvalidArgumentException(
'A valid response status line was not found in the provided string'
);
}
$this->version = $matches['version'];
$this->setStatusCode($matches['status']);
$this->setReasonPhrase((isset($matches['reason']) ? $matches['reason'] : ''));
}
/**
* @return Header\SetCookie[]
*/
@@ -249,7 +280,7 @@ class Response extends AbstractMessage implements ResponseInterface
public function setStatusCode($code)
{
$const = get_class($this) . '::STATUS_CODE_' . $code;
if (!is_numeric($code) || !defined($const)) {
if (! is_numeric($code) || ! defined($const)) {
$code = is_scalar($code) ? $code : gettype($code);
throw new Exception\InvalidArgumentException(sprintf(
'Invalid status code provided: "%s"',
@@ -279,7 +310,7 @@ class Response extends AbstractMessage implements ResponseInterface
*/
public function setCustomStatusCode($code)
{
if (!is_numeric($code)) {
if (! is_numeric($code)) {
$code = is_scalar($code) ? $code : gettype($code);
throw new Exception\InvalidArgumentException(sprintf(
'Invalid status code provided: "%s"',
@@ -320,7 +351,7 @@ class Response extends AbstractMessage implements ResponseInterface
*/
public function getReasonPhrase()
{
if (null == $this->reasonPhrase and isset($this->recommendedReasonPhrases[$this->statusCode])) {
if (null == $this->reasonPhrase && isset($this->recommendedReasonPhrases[$this->statusCode])) {
$this->reasonPhrase = $this->recommendedReasonPhrases[$this->statusCode];
}
return $this->reasonPhrase;
@@ -337,7 +368,7 @@ class Response extends AbstractMessage implements ResponseInterface
$transferEncoding = $this->getHeaders()->get('Transfer-Encoding');
if (!empty($transferEncoding)) {
if (! empty($transferEncoding)) {
if (strtolower($transferEncoding->getFieldValue()) === 'chunked') {
$body = $this->decodeChunkedBody($body);
}
@@ -345,7 +376,7 @@ class Response extends AbstractMessage implements ResponseInterface
$contentEncoding = $this->getHeaders()->get('Content-Encoding');
if (!empty($contentEncoding)) {
if (! empty($contentEncoding)) {
$contentEncoding = $contentEncoding->getFieldValue();
if ($contentEncoding === 'gzip') {
$body = $this->decodeGzip($body);
@@ -399,6 +430,16 @@ class Response extends AbstractMessage implements ResponseInterface
return (404 === $this->getStatusCode());
}
/**
* Does the status code indicate the resource is gone?
*
* @return bool
*/
public function isGone()
{
return (410 === $this->getStatusCode());
}
/**
* Do we have a normal, OK response?
*
@@ -483,17 +524,24 @@ class Response extends AbstractMessage implements ResponseInterface
{
$decBody = '';
while (trim($body)) {
if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m)) {
throw new Exception\RuntimeException(
"Error parsing body - doesn't seem to be a chunked message"
);
$offset = 0;
while (true) {
if (! preg_match("/^([\da-fA-F]+)[^\r\n]*\r\n/sm", $body, $m, 0, $offset)) {
if (trim(substr($body, $offset))) {
// Message was not consumed completely!
throw new Exception\RuntimeException(
'Error parsing body - doesn\'t seem to be a chunked message'
);
}
// Message was consumed completely
break;
}
$length = hexdec(trim($m[1]));
$cut = strlen($m[0]);
$decBody .= substr($body, $cut, $length);
$body = substr($body, $cut + $length + 2);
$decBody .= substr($body, $offset + $cut, $length);
$offset += $cut + $length + 2;
}
return $decBody;
@@ -510,7 +558,7 @@ class Response extends AbstractMessage implements ResponseInterface
*/
protected function decodeGzip($body)
{
if (!function_exists('gzinflate')) {
if (! function_exists('gzinflate')) {
throw new Exception\RuntimeException(
'zlib extension is required in order to decode "gzip" encoding'
);
@@ -540,7 +588,7 @@ class Response extends AbstractMessage implements ResponseInterface
*/
protected function decodeDeflate($body)
{
if (!function_exists('gzuncompress')) {
if (! function_exists('gzuncompress')) {
throw new Exception\RuntimeException(
'zlib extension is required in order to decode "deflate" encoding'
);