Update to laravel 7

This commit is contained in:
KodeStar
2022-03-10 11:54:29 +00:00
parent 61a5a1a8b0
commit f9a19fce91
7170 changed files with 274189 additions and 283773 deletions

View File

@@ -17,16 +17,23 @@ class FullHttpMessageFormatter implements Formatter
/**
* The maximum length of the body.
*
* @var int
* @var int|null
*/
private $maxBodyLength;
/**
* @param int $maxBodyLength
* @var string
*/
public function __construct($maxBodyLength = 1000)
private $binaryDetectionRegex;
/**
* @param int|null $maxBodyLength
* @param string $binaryDetectionRegex By default, this is all non-printable ASCII characters and <DEL> except for \t, \r, \n
*/
public function __construct($maxBodyLength = 1000, string $binaryDetectionRegex = '/([\x00-\x09\x0C\x0E-\x1F\x7F])/')
{
$this->maxBodyLength = $maxBodyLength;
$this->binaryDetectionRegex = $binaryDetectionRegex;
}
/**
@@ -67,25 +74,43 @@ class FullHttpMessageFormatter implements Formatter
return $this->addBody($response, $message);
}
/**
* Formats a response in context of its request.
*
* @return string
*/
public function formatResponseForRequest(ResponseInterface $response, RequestInterface $request)
{
return $this->formatResponse($response);
}
/**
* Add the message body if the stream is seekable.
*
* @param MessageInterface $request
* @param string $message
* @param string $message
*
* @return string
*/
private function addBody(MessageInterface $request, $message)
{
$message .= "\n";
$stream = $request->getBody();
if (!$stream->isSeekable() || 0 === $this->maxBodyLength) {
// Do not read the stream
$message .= "\n";
} else {
$message .= "\n".mb_substr($stream->__toString(), 0, $this->maxBodyLength);
$stream->rewind();
return $message;
}
return $message;
$data = $stream->__toString();
$stream->rewind();
if (preg_match($this->binaryDetectionRegex, $data)) {
return $message.'[binary stream omitted]';
}
if (null === $this->maxBodyLength) {
return $message.$data;
}
return $message.mb_substr($data, 0, $this->maxBodyLength);
}
}