Laravel 5.6 updates

Travis config update

Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -194,13 +194,9 @@ class Response
);
/**
* @param mixed $content The response content, see setContent()
* @param int $status The response status code
* @param array $headers An array of response headers
*
* @throws \InvalidArgumentException When the HTTP status code is not valid
*/
public function __construct($content = '', $status = 200, $headers = array())
public function __construct($content = '', int $status = 200, array $headers = array())
{
$this->headers = new ResponseHeaderBag($headers);
$this->setContent($content);
@@ -416,13 +412,11 @@ class Response
/**
* Sets the HTTP protocol version (1.0 or 1.1).
*
* @param string $version The HTTP protocol version
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setProtocolVersion($version)
public function setProtocolVersion(string $version)
{
$this->version = $version;
@@ -432,11 +426,9 @@ class Response
/**
* Gets the HTTP protocol version.
*
* @return string The HTTP protocol version
*
* @final since version 3.2
* @final
*/
public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->version;
}
@@ -447,18 +439,15 @@ class Response
* If the status text is null it will be automatically populated for the known
* status codes and left empty otherwise.
*
* @param int $code HTTP status code
* @param mixed $text HTTP status text
*
* @return $this
*
* @throws \InvalidArgumentException When the HTTP status code is not valid
*
* @final since version 3.2
* @final
*/
public function setStatusCode($code, $text = null)
public function setStatusCode(int $code, $text = null)
{
$this->statusCode = $code = (int) $code;
$this->statusCode = $code;
if ($this->isInvalid()) {
throw new \InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $code));
}
@@ -483,11 +472,9 @@ class Response
/**
* Retrieves the status code for the current web response.
*
* @return int Status code
*
* @final since version 3.2
* @final
*/
public function getStatusCode()
public function getStatusCode(): int
{
return $this->statusCode;
}
@@ -495,13 +482,11 @@ class Response
/**
* Sets the response charset.
*
* @param string $charset Character set
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setCharset($charset)
public function setCharset(string $charset)
{
$this->charset = $charset;
@@ -511,11 +496,9 @@ class Response
/**
* Retrieves the response charset.
*
* @return string Character set
*
* @final since version 3.2
* @final
*/
public function getCharset()
public function getCharset(): ?string
{
return $this->charset;
}
@@ -535,11 +518,9 @@ class Response
* can be reused by a cache with heuristic expiration unless otherwise indicated"
* (https://tools.ietf.org/html/rfc7231#section-6.1)
*
* @return bool true if the response is worth caching, false otherwise
*
* @final since version 3.3
* @final
*/
public function isCacheable()
public function isCacheable(): bool
{
if (!\in_array($this->statusCode, array(200, 203, 300, 301, 302, 404, 410))) {
return false;
@@ -559,11 +540,9 @@ class Response
* origin. A response is considered fresh when it includes a Cache-Control/max-age
* indicator or Expires header and the calculated age is less than the freshness lifetime.
*
* @return bool true if the response is fresh, false otherwise
*
* @final since version 3.3
* @final
*/
public function isFresh()
public function isFresh(): bool
{
return $this->getTtl() > 0;
}
@@ -572,11 +551,9 @@ class Response
* Returns true if the response includes headers that can be used to validate
* the response with the origin server using a conditional GET request.
*
* @return bool true if the response is validateable, false otherwise
*
* @final since version 3.3
* @final
*/
public function isValidateable()
public function isValidateable(): bool
{
return $this->headers->has('Last-Modified') || $this->headers->has('ETag');
}
@@ -588,7 +565,7 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setPrivate()
{
@@ -605,7 +582,7 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setPublic()
{
@@ -618,13 +595,11 @@ class Response
/**
* Marks the response as "immutable".
*
* @param bool $immutable enables or disables the immutable directive
*
* @return $this
*
* @final
*/
public function setImmutable($immutable = true)
public function setImmutable(bool $immutable = true)
{
if ($immutable) {
$this->headers->addCacheControlDirective('immutable');
@@ -638,11 +613,9 @@ class Response
/**
* Returns true if the response is marked as "immutable".
*
* @return bool returns true if the response is marked as "immutable"; otherwise false
*
* @final
*/
public function isImmutable()
public function isImmutable(): bool
{
return $this->headers->hasCacheControlDirective('immutable');
}
@@ -655,11 +628,9 @@ class Response
* When present, the TTL of the response should not be overridden to be
* greater than the value provided by the origin.
*
* @return bool true if the response must be revalidated by a cache, false otherwise
*
* @final since version 3.3
* @final
*/
public function mustRevalidate()
public function mustRevalidate(): bool
{
return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->hasCacheControlDirective('proxy-revalidate');
}
@@ -667,13 +638,11 @@ class Response
/**
* Returns the Date header as a DateTime instance.
*
* @return \DateTime A \DateTime instance
*
* @throws \RuntimeException When the header is not parseable
*
* @final since version 3.2
* @final
*/
public function getDate()
public function getDate(): ?\DateTimeInterface
{
return $this->headers->getDate('Date');
}
@@ -683,24 +652,26 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setDate(\DateTime $date)
public function setDate(\DateTimeInterface $date)
{
$date->setTimezone(new \DateTimeZone('UTC'));
if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date);
}
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
/**
* Returns the age of the response.
* Returns the age of the response in seconds.
*
* @return int The age of the response in seconds
*
* @final since version 3.2
* @final
*/
public function getAge()
public function getAge(): int
{
if (null !== $age = $this->headers->get('Age')) {
return (int) $age;
@@ -726,17 +697,15 @@ class Response
/**
* Returns the value of the Expires header as a DateTime instance.
*
* @return \DateTime|null A DateTime instance or null if the header does not exist
*
* @final since version 3.2
* @final
*/
public function getExpires()
public function getExpires(): ?\DateTimeInterface
{
try {
return $this->headers->getDate('Expires');
} catch (\RuntimeException $e) {
// according to RFC 2616 invalid date formats (e.g. "0" and "-1") must be treated as in the past
return \DateTime::createFromFormat(DATE_RFC2822, 'Sat, 01 Jan 00 00:00:00 +0000');
return \DateTime::createFromFormat('U', time() - 172800);
}
}
@@ -745,22 +714,25 @@ class Response
*
* Passing null as value will remove the header.
*
* @param \DateTime|null $date A \DateTime instance or null to remove the header
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setExpires(\DateTime $date = null)
public function setExpires(\DateTimeInterface $date = null)
{
if (null === $date) {
$this->headers->remove('Expires');
} else {
$date = clone $date;
$date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date);
}
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Expires', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
@@ -771,11 +743,9 @@ class Response
* First, it checks for a s-maxage directive, then a max-age directive, and then it falls
* back on an expires header. It returns null when no maximum age can be established.
*
* @return int|null Number of seconds
*
* @final since version 3.2
* @final
*/
public function getMaxAge()
public function getMaxAge(): ?int
{
if ($this->headers->hasCacheControlDirective('s-maxage')) {
return (int) $this->headers->getCacheControlDirective('s-maxage');
@@ -786,8 +756,10 @@ class Response
}
if (null !== $this->getExpires()) {
return $this->getExpires()->format('U') - $this->getDate()->format('U');
return (int) ($this->getExpires()->format('U') - $this->getDate()->format('U'));
}
return null;
}
/**
@@ -795,13 +767,11 @@ class Response
*
* This methods sets the Cache-Control max-age directive.
*
* @param int $value Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setMaxAge($value)
public function setMaxAge(int $value)
{
$this->headers->addCacheControlDirective('max-age', $value);
@@ -813,13 +783,11 @@ class Response
*
* This methods sets the Cache-Control s-maxage directive.
*
* @param int $value Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setSharedMaxAge($value)
public function setSharedMaxAge(int $value)
{
$this->setPublic();
$this->headers->addCacheControlDirective('s-maxage', $value);
@@ -835,29 +803,25 @@ class Response
* When the responses TTL is <= 0, the response may not be served from cache without first
* revalidating with the origin.
*
* @return int|null The TTL in seconds
*
* @final since version 3.2
* @final
*/
public function getTtl()
public function getTtl(): ?int
{
if (null !== $maxAge = $this->getMaxAge()) {
return $maxAge - $this->getAge();
}
$maxAge = $this->getMaxAge();
return null !== $maxAge ? $maxAge - $this->getAge() : null;
}
/**
* Sets the response's time-to-live for shared caches.
* Sets the response's time-to-live for shared caches in seconds.
*
* This method adjusts the Cache-Control/s-maxage directive.
*
* @param int $seconds Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setTtl($seconds)
public function setTtl(int $seconds)
{
$this->setSharedMaxAge($this->getAge() + $seconds);
@@ -865,17 +829,15 @@ class Response
}
/**
* Sets the response's time-to-live for private/client caches.
* Sets the response's time-to-live for private/client caches in seconds.
*
* This method adjusts the Cache-Control/max-age directive.
*
* @param int $seconds Number of seconds
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setClientTtl($seconds)
public function setClientTtl(int $seconds)
{
$this->setMaxAge($this->getAge() + $seconds);
@@ -885,13 +847,11 @@ class Response
/**
* Returns the Last-Modified HTTP header as a DateTime instance.
*
* @return \DateTime|null A DateTime instance or null if the header does not exist
*
* @throws \RuntimeException When the HTTP header is not parseable
*
* @final since version 3.2
* @final
*/
public function getLastModified()
public function getLastModified(): ?\DateTimeInterface
{
return $this->headers->getDate('Last-Modified');
}
@@ -901,33 +861,34 @@ class Response
*
* Passing null as value will remove the header.
*
* @param \DateTime|null $date A \DateTime instance or null to remove the header
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setLastModified(\DateTime $date = null)
public function setLastModified(\DateTimeInterface $date = null)
{
if (null === $date) {
$this->headers->remove('Last-Modified');
} else {
$date = clone $date;
$date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
if ($date instanceof \DateTime) {
$date = \DateTimeImmutable::createFromMutable($date);
}
$date = $date->setTimezone(new \DateTimeZone('UTC'));
$this->headers->set('Last-Modified', $date->format('D, d M Y H:i:s').' GMT');
return $this;
}
/**
* Returns the literal value of the ETag HTTP header.
*
* @return string|null The ETag HTTP header or null if it does not exist
*
* @final since version 3.2
* @final
*/
public function getEtag()
public function getEtag(): ?string
{
return $this->headers->get('ETag');
}
@@ -940,9 +901,9 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setEtag($etag = null, $weak = false)
public function setEtag(string $etag = null, bool $weak = false)
{
if (null === $etag) {
$this->headers->remove('Etag');
@@ -962,13 +923,11 @@ class Response
*
* Available options are: etag, last_modified, max_age, s_maxage, private, public and immutable.
*
* @param array $options An array of cache options
*
* @return $this
*
* @throws \InvalidArgumentException
*
* @final since version 3.3
* @final
*/
public function setCache(array $options)
{
@@ -1025,7 +984,7 @@ class Response
*
* @see http://tools.ietf.org/html/rfc2616#section-10.3.5
*
* @final since version 3.3
* @final
*/
public function setNotModified()
{
@@ -1043,11 +1002,9 @@ class Response
/**
* Returns true if the response includes a Vary header.
*
* @return bool true if the response includes a Vary header, false otherwise
*
* @final since version 3.2
* @final
*/
public function hasVary()
public function hasVary(): bool
{
return null !== $this->headers->get('Vary');
}
@@ -1055,11 +1012,9 @@ class Response
/**
* Returns an array of header names given in the Vary header.
*
* @return array An array of Vary names
*
* @final since version 3.2
* @final
*/
public function getVary()
public function getVary(): array
{
if (!$vary = $this->headers->get('Vary', null, false)) {
return array();
@@ -1081,9 +1036,9 @@ class Response
*
* @return $this
*
* @final since version 3.2
* @final
*/
public function setVary($headers, $replace = true)
public function setVary($headers, bool $replace = true)
{
$this->headers->set('Vary', $headers, $replace);
@@ -1099,9 +1054,9 @@ class Response
*
* @return bool true if the Response validators match the Request, false otherwise
*
* @final since version 3.3
* @final
*/
public function isNotModified(Request $request)
public function isNotModified(Request $request): bool
{
if (!$request->isMethodCacheable()) {
return false;
@@ -1129,13 +1084,11 @@ class Response
/**
* Is response invalid?
*
* @return bool
*
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
*
* @final since version 3.2
* @final
*/
public function isInvalid()
public function isInvalid(): bool
{
return $this->statusCode < 100 || $this->statusCode >= 600;
}
@@ -1143,11 +1096,9 @@ class Response
/**
* Is response informative?
*
* @return bool
*
* @final since version 3.3
* @final
*/
public function isInformational()
public function isInformational(): bool
{
return $this->statusCode >= 100 && $this->statusCode < 200;
}
@@ -1155,11 +1106,9 @@ class Response
/**
* Is response successful?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isSuccessful()
public function isSuccessful(): bool
{
return $this->statusCode >= 200 && $this->statusCode < 300;
}
@@ -1167,11 +1116,9 @@ class Response
/**
* Is the response a redirect?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isRedirection()
public function isRedirection(): bool
{
return $this->statusCode >= 300 && $this->statusCode < 400;
}
@@ -1179,11 +1126,9 @@ class Response
/**
* Is there a client error?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isClientError()
public function isClientError(): bool
{
return $this->statusCode >= 400 && $this->statusCode < 500;
}
@@ -1191,11 +1136,9 @@ class Response
/**
* Was there a server side error?
*
* @return bool
*
* @final since version 3.3
* @final
*/
public function isServerError()
public function isServerError(): bool
{
return $this->statusCode >= 500 && $this->statusCode < 600;
}
@@ -1203,11 +1146,9 @@ class Response
/**
* Is the response OK?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isOk()
public function isOk(): bool
{
return 200 === $this->statusCode;
}
@@ -1215,11 +1156,9 @@ class Response
/**
* Is the response forbidden?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isForbidden()
public function isForbidden(): bool
{
return 403 === $this->statusCode;
}
@@ -1227,11 +1166,9 @@ class Response
/**
* Is the response a not found error?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isNotFound()
public function isNotFound(): bool
{
return 404 === $this->statusCode;
}
@@ -1239,13 +1176,9 @@ class Response
/**
* Is the response a redirect of some form?
*
* @param string $location
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isRedirect($location = null)
public function isRedirect(string $location = null): bool
{
return \in_array($this->statusCode, array(201, 301, 302, 303, 307, 308)) && (null === $location ?: $location == $this->headers->get('Location'));
}
@@ -1253,11 +1186,9 @@ class Response
/**
* Is the response empty?
*
* @return bool
*
* @final since version 3.2
* @final
*/
public function isEmpty()
public function isEmpty(): bool
{
return \in_array($this->statusCode, array(204, 304));
}
@@ -1267,17 +1198,13 @@ class Response
*
* Resulting level can be greater than target level if a non-removable buffer has been encountered.
*
* @param int $targetLevel The target output buffering level
* @param bool $flush Whether to flush or clean the buffers
*
* @final since version 3.3
* @final
*/
public static function closeOutputBuffers($targetLevel, $flush)
public static function closeOutputBuffers(int $targetLevel, bool $flush)
{
$status = ob_get_status(true);
$level = \count($status);
// PHP_OUTPUT_HANDLER_* are not defined on HHVM 3.3
$flags = \defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1;
$flags = PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE);
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) {
if ($flush) {
@@ -1293,7 +1220,7 @@ class Response
*
* @see http://support.microsoft.com/kb/323308
*
* @final since version 3.3
* @final
*/
protected function ensureIEOverSSLCompatibility(Request $request)
{