Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
vendor/symfony/psr-http-message-bridge/Factory
170
vendor/symfony/psr-http-message-bridge/Factory/DiactorosFactory.php
vendored
Normal file
170
vendor/symfony/psr-http-message-bridge/Factory/DiactorosFactory.php
vendored
Normal file
|
@ -0,0 +1,170 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Factory;
|
||||
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Zend\Diactoros\Response as DiactorosResponse;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
use Zend\Diactoros\ServerRequestFactory as DiactorosRequestFactory;
|
||||
use Zend\Diactoros\Stream as DiactorosStream;
|
||||
use Zend\Diactoros\UploadedFile as DiactorosUploadedFile;
|
||||
|
||||
/**
|
||||
* Builds Psr\HttpMessage instances using the Zend Diactoros implementation.
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class DiactorosFactory implements HttpMessageFactoryInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (!class_exists('Zend\Diactoros\ServerRequestFactory')) {
|
||||
throw new \RuntimeException('Zend Diactoros must be installed to use the DiactorosFactory.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createRequest(Request $symfonyRequest)
|
||||
{
|
||||
$server = DiactorosRequestFactory::normalizeServer($symfonyRequest->server->all());
|
||||
$headers = $symfonyRequest->headers->all();
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
$body = new DiactorosStream('php://temp', 'wb+');
|
||||
$body->write($symfonyRequest->getContent());
|
||||
} else {
|
||||
$body = new DiactorosStream($symfonyRequest->getContent(true));
|
||||
}
|
||||
|
||||
$request = new ServerRequest(
|
||||
$server,
|
||||
DiactorosRequestFactory::normalizeFiles($this->getFiles($symfonyRequest->files->all())),
|
||||
$symfonyRequest->getSchemeAndHttpHost().$symfonyRequest->getRequestUri(),
|
||||
$symfonyRequest->getMethod(),
|
||||
$body,
|
||||
$headers
|
||||
);
|
||||
|
||||
$request = $request
|
||||
->withCookieParams($symfonyRequest->cookies->all())
|
||||
->withQueryParams($symfonyRequest->query->all())
|
||||
->withParsedBody($symfonyRequest->request->all())
|
||||
->withRequestTarget($symfonyRequest->getRequestUri())
|
||||
;
|
||||
|
||||
foreach ($symfonyRequest->attributes->all() as $key => $value) {
|
||||
$request = $request->withAttribute($key, $value);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Symfony uploaded files array to the PSR one.
|
||||
*
|
||||
* @param array $uploadedFiles
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFiles(array $uploadedFiles)
|
||||
{
|
||||
$files = array();
|
||||
|
||||
foreach ($uploadedFiles as $key => $value) {
|
||||
if (null === $value) {
|
||||
$files[$key] = new DiactorosUploadedFile(null, 0, UPLOAD_ERR_NO_FILE, null, null);
|
||||
continue;
|
||||
}
|
||||
if ($value instanceof UploadedFile) {
|
||||
$files[$key] = $this->createUploadedFile($value);
|
||||
} else {
|
||||
$files[$key] = $this->getFiles($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PSR-7 UploadedFile instance from a Symfony one.
|
||||
*
|
||||
* @param UploadedFile $symfonyUploadedFile
|
||||
*
|
||||
* @return UploadedFileInterface
|
||||
*/
|
||||
private function createUploadedFile(UploadedFile $symfonyUploadedFile)
|
||||
{
|
||||
return new DiactorosUploadedFile(
|
||||
$symfonyUploadedFile->getRealPath(),
|
||||
(int) $symfonyUploadedFile->getSize(),
|
||||
$symfonyUploadedFile->getError(),
|
||||
$symfonyUploadedFile->getClientOriginalName(),
|
||||
$symfonyUploadedFile->getClientMimeType()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createResponse(Response $symfonyResponse)
|
||||
{
|
||||
if ($symfonyResponse instanceof BinaryFileResponse) {
|
||||
$stream = new DiactorosStream($symfonyResponse->getFile()->getPathname(), 'r');
|
||||
} else {
|
||||
$stream = new DiactorosStream('php://temp', 'wb+');
|
||||
if ($symfonyResponse instanceof StreamedResponse) {
|
||||
ob_start(function ($buffer) use ($stream) {
|
||||
$stream->write($buffer);
|
||||
|
||||
return '';
|
||||
});
|
||||
|
||||
$symfonyResponse->sendContent();
|
||||
ob_end_clean();
|
||||
} else {
|
||||
$stream->write($symfonyResponse->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
$headers = $symfonyResponse->headers->all();
|
||||
if (!isset($headers['Set-Cookie']) && !isset($headers['set-sookie'])) {
|
||||
$cookies = $symfonyResponse->headers->getCookies();
|
||||
if (!empty($cookies)) {
|
||||
$headers['Set-Cookie'] = array();
|
||||
foreach ($cookies as $cookie) {
|
||||
$headers['Set-Cookie'][] = $cookie->__toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$response = new DiactorosResponse(
|
||||
$stream,
|
||||
$symfonyResponse->getStatusCode(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$protocolVersion = $symfonyResponse->getProtocolVersion();
|
||||
if ('1.1' !== $protocolVersion) {
|
||||
$response = $response->withProtocolVersion($protocolVersion);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
229
vendor/symfony/psr-http-message-bridge/Factory/HttpFoundationFactory.php
vendored
Normal file
229
vendor/symfony/psr-http-message-bridge/Factory/HttpFoundationFactory.php
vendored
Normal file
|
@ -0,0 +1,229 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Factory;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
class HttpFoundationFactory implements HttpFoundationFactoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createRequest(ServerRequestInterface $psrRequest)
|
||||
{
|
||||
$server = array();
|
||||
$uri = $psrRequest->getUri();
|
||||
|
||||
if ($uri instanceof UriInterface) {
|
||||
$server['SERVER_NAME'] = $uri->getHost();
|
||||
$server['SERVER_PORT'] = $uri->getPort();
|
||||
$server['REQUEST_URI'] = $uri->getPath();
|
||||
$server['QUERY_STRING'] = $uri->getQuery();
|
||||
}
|
||||
|
||||
$server['REQUEST_METHOD'] = $psrRequest->getMethod();
|
||||
|
||||
$server = array_replace($server, $psrRequest->getServerParams());
|
||||
|
||||
$parsedBody = $psrRequest->getParsedBody();
|
||||
$parsedBody = is_array($parsedBody) ? $parsedBody : array();
|
||||
|
||||
$request = new Request(
|
||||
$psrRequest->getQueryParams(),
|
||||
$parsedBody,
|
||||
$psrRequest->getAttributes(),
|
||||
$psrRequest->getCookieParams(),
|
||||
$this->getFiles($psrRequest->getUploadedFiles()),
|
||||
$server,
|
||||
$psrRequest->getBody()->__toString()
|
||||
);
|
||||
$request->headers->replace($psrRequest->getHeaders());
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to the input array to $_FILES structure.
|
||||
*
|
||||
* @param array $uploadedFiles
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFiles(array $uploadedFiles)
|
||||
{
|
||||
$files = array();
|
||||
|
||||
foreach ($uploadedFiles as $key => $value) {
|
||||
if ($value instanceof UploadedFileInterface) {
|
||||
$files[$key] = $this->createUploadedFile($value);
|
||||
} else {
|
||||
$files[$key] = $this->getFiles($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates Symfony UploadedFile instance from PSR-7 ones.
|
||||
*
|
||||
* @param UploadedFileInterface $psrUploadedFile
|
||||
*
|
||||
* @return UploadedFile
|
||||
*/
|
||||
private function createUploadedFile(UploadedFileInterface $psrUploadedFile)
|
||||
{
|
||||
$temporaryPath = '';
|
||||
$clientFileName = '';
|
||||
if (UPLOAD_ERR_NO_FILE !== $psrUploadedFile->getError()) {
|
||||
$temporaryPath = $this->getTemporaryPath();
|
||||
$psrUploadedFile->moveTo($temporaryPath);
|
||||
|
||||
$clientFileName = $psrUploadedFile->getClientFilename();
|
||||
}
|
||||
|
||||
if (class_exists('Symfony\Component\HttpFoundation\HeaderUtils')) {
|
||||
// Symfony 4.1+
|
||||
return new UploadedFile(
|
||||
$temporaryPath,
|
||||
null === $clientFileName ? '' : $clientFileName,
|
||||
$psrUploadedFile->getClientMediaType(),
|
||||
$psrUploadedFile->getError(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return new UploadedFile(
|
||||
$temporaryPath,
|
||||
null === $clientFileName ? '' : $clientFileName,
|
||||
$psrUploadedFile->getClientMediaType(),
|
||||
$psrUploadedFile->getSize(),
|
||||
$psrUploadedFile->getError(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a temporary file path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemporaryPath()
|
||||
{
|
||||
return tempnam(sys_get_temp_dir(), uniqid('symfony', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createResponse(ResponseInterface $psrResponse)
|
||||
{
|
||||
$response = new Response(
|
||||
$psrResponse->getBody()->__toString(),
|
||||
$psrResponse->getStatusCode(),
|
||||
$psrResponse->getHeaders()
|
||||
);
|
||||
$response->setProtocolVersion($psrResponse->getProtocolVersion());
|
||||
|
||||
foreach ($psrResponse->getHeader('Set-Cookie') as $cookie) {
|
||||
$response->headers->setCookie($this->createCookie($cookie));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Cookie instance from a cookie string.
|
||||
*
|
||||
* Some snippets have been taken from the Guzzle project: https://github.com/guzzle/guzzle/blob/5.3/src/Cookie/SetCookie.php#L34
|
||||
*
|
||||
* @param string $cookie
|
||||
*
|
||||
* @return Cookie
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
private function createCookie($cookie)
|
||||
{
|
||||
foreach (explode(';', $cookie) as $part) {
|
||||
$part = trim($part);
|
||||
|
||||
$data = explode('=', $part, 2);
|
||||
$name = $data[0];
|
||||
$value = isset($data[1]) ? trim($data[1], " \n\r\t\0\x0B\"") : null;
|
||||
|
||||
if (!isset($cookieName)) {
|
||||
$cookieName = $name;
|
||||
$cookieValue = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('expires' === strtolower($name) && null !== $value) {
|
||||
$cookieExpire = new \DateTime($value);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('path' === strtolower($name) && null !== $value) {
|
||||
$cookiePath = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('domain' === strtolower($name) && null !== $value) {
|
||||
$cookieDomain = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('secure' === strtolower($name)) {
|
||||
$cookieSecure = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ('httponly' === strtolower($name)) {
|
||||
$cookieHttpOnly = true;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($cookieName)) {
|
||||
throw new \InvalidArgumentException('The value of the Set-Cookie header is malformed.');
|
||||
}
|
||||
|
||||
return new Cookie(
|
||||
$cookieName,
|
||||
$cookieValue,
|
||||
isset($cookieExpire) ? $cookieExpire : 0,
|
||||
isset($cookiePath) ? $cookiePath : '/',
|
||||
isset($cookieDomain) ? $cookieDomain : null,
|
||||
isset($cookieSecure),
|
||||
isset($cookieHttpOnly)
|
||||
);
|
||||
}
|
||||
}
|
177
vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php
vendored
Normal file
177
vendor/symfony/psr-http-message-bridge/Factory/PsrHttpFactory.php
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PsrHttpMessage\Factory;
|
||||
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ServerRequestFactoryInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UploadedFileFactoryInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* Builds Psr\HttpMessage instances using a PSR-17 implementation.
|
||||
*
|
||||
* @author Antonio J. García Lagar <aj@garcialagar.es>
|
||||
*/
|
||||
class PsrHttpFactory implements HttpMessageFactoryInterface
|
||||
{
|
||||
private $serverRequestFactory;
|
||||
private $streamFactory;
|
||||
private $uploadedFileFactory;
|
||||
private $responseFactory;
|
||||
|
||||
public function __construct(ServerRequestFactoryInterface $serverRequestFactory, StreamFactoryInterface $streamFactory, UploadedFileFactoryInterface $uploadedFileFactory, ResponseFactoryInterface $responseFactory)
|
||||
{
|
||||
$this->serverRequestFactory = $serverRequestFactory;
|
||||
$this->streamFactory = $streamFactory;
|
||||
$this->uploadedFileFactory = $uploadedFileFactory;
|
||||
$this->responseFactory = $responseFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createRequest(Request $symfonyRequest)
|
||||
{
|
||||
$request = $this->serverRequestFactory->createServerRequest(
|
||||
$symfonyRequest->getMethod(),
|
||||
$symfonyRequest->getSchemeAndHttpHost().$symfonyRequest->getRequestUri(),
|
||||
$symfonyRequest->server->all()
|
||||
);
|
||||
|
||||
foreach ($symfonyRequest->headers->all() as $name => $value) {
|
||||
$request = $request->withHeader($name, $value);
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
$body = $this->streamFactory->createStreamFromFile('php://temp', 'wb+');
|
||||
$body->write($symfonyRequest->getContent());
|
||||
} else {
|
||||
$body = $this->streamFactory->createStreamFromResource($symfonyRequest->getContent(true));
|
||||
}
|
||||
|
||||
$request = $request
|
||||
->withBody($body)
|
||||
->withUploadedFiles($this->getFiles($symfonyRequest->files->all()))
|
||||
->withCookieParams($symfonyRequest->cookies->all())
|
||||
->withQueryParams($symfonyRequest->query->all())
|
||||
->withParsedBody($symfonyRequest->request->all())
|
||||
;
|
||||
|
||||
foreach ($symfonyRequest->attributes->all() as $key => $value) {
|
||||
$request = $request->withAttribute($key, $value);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Symfony uploaded files array to the PSR one.
|
||||
*
|
||||
* @param array $uploadedFiles
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFiles(array $uploadedFiles)
|
||||
{
|
||||
$files = array();
|
||||
|
||||
foreach ($uploadedFiles as $key => $value) {
|
||||
if (null === $value) {
|
||||
$files[$key] = $this->uploadedFileFactory->createUploadedFile($this->streamFactory->createStream(), 0, UPLOAD_ERR_NO_FILE);
|
||||
continue;
|
||||
}
|
||||
if ($value instanceof UploadedFile) {
|
||||
$files[$key] = $this->createUploadedFile($value);
|
||||
} else {
|
||||
$files[$key] = $this->getFiles($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a PSR-7 UploadedFile instance from a Symfony one.
|
||||
*
|
||||
* @param UploadedFile $symfonyUploadedFile
|
||||
*
|
||||
* @return UploadedFileInterface
|
||||
*/
|
||||
private function createUploadedFile(UploadedFile $symfonyUploadedFile)
|
||||
{
|
||||
return $this->uploadedFileFactory->createUploadedFile(
|
||||
$this->streamFactory->createStreamFromFile(
|
||||
$symfonyUploadedFile->getRealPath()
|
||||
),
|
||||
(int) $symfonyUploadedFile->getSize(),
|
||||
$symfonyUploadedFile->getError(),
|
||||
$symfonyUploadedFile->getClientOriginalName(),
|
||||
$symfonyUploadedFile->getClientMimeType()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createResponse(Response $symfonyResponse)
|
||||
{
|
||||
$response = $this->responseFactory->createResponse($symfonyResponse->getStatusCode());
|
||||
|
||||
if ($symfonyResponse instanceof BinaryFileResponse) {
|
||||
$stream = $this->streamFactory->createStreamFromFile(
|
||||
$symfonyResponse->getFile()->getPathname()
|
||||
);
|
||||
} else {
|
||||
$stream = $this->streamFactory->createStreamFromFile('php://temp', 'wb+');
|
||||
if ($symfonyResponse instanceof StreamedResponse) {
|
||||
ob_start(function ($buffer) use ($stream) {
|
||||
$stream->write($buffer);
|
||||
|
||||
return '';
|
||||
});
|
||||
|
||||
$symfonyResponse->sendContent();
|
||||
ob_end_clean();
|
||||
} else {
|
||||
$stream->write($symfonyResponse->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
$response = $response->withBody($stream);
|
||||
|
||||
$headers = $symfonyResponse->headers->all();
|
||||
$cookies = $symfonyResponse->headers->getCookies();
|
||||
if (!empty($cookies)) {
|
||||
$headers['Set-Cookie'] = array();
|
||||
|
||||
foreach ($cookies as $cookie) {
|
||||
$headers['Set-Cookie'][] = $cookie->__toString();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($headers as $name => $value) {
|
||||
$response = $response->withHeader($name, $value);
|
||||
}
|
||||
|
||||
$protocolVersion = $symfonyResponse->getProtocolVersion();
|
||||
$response = $response->withProtocolVersion($protocolVersion);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
Reference in a new issue