migration symfony 5 4 (#300)

* symfony 5.4 (diff dev)

* symfony 5.4 (working)

* symfony 5.4 (update autoload)

* symfony 5.4 (remove swiftmailer mailer implementation)

* symfony 5.4 (php doc and split Global accessor class)


### Impacted packages:

composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies

composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -33,17 +33,7 @@ class RequestContext
private $queryString;
private $parameters = [];
/**
* @param string $baseUrl The base URL
* @param string $method The HTTP method
* @param string $host The HTTP host name
* @param string $scheme The HTTP scheme
* @param int $httpPort The HTTP port
* @param int $httpsPort The HTTPS port
* @param string $path The path
* @param string $queryString The query string
*/
public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '')
public function __construct(string $baseUrl = '', string $method = 'GET', string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443, string $path = '/', string $queryString = '')
{
$this->setBaseUrl($baseUrl);
$this->setMethod($method);
@@ -55,6 +45,23 @@ class RequestContext
$this->setQueryString($queryString);
}
public static function fromUri(string $uri, string $host = 'localhost', string $scheme = 'http', int $httpPort = 80, int $httpsPort = 443): self
{
$uri = parse_url($uri);
$scheme = $uri['scheme'] ?? $scheme;
$host = $uri['host'] ?? $host;
if (isset($uri['port'])) {
if ('http' === $scheme) {
$httpPort = $uri['port'];
} elseif ('https' === $scheme) {
$httpsPort = $uri['port'];
}
}
return new self($uri['path'] ?? '', 'GET', $host, $scheme, $httpPort, $httpsPort);
}
/**
* Updates the RequestContext information based on a HttpFoundation Request.
*
@@ -77,7 +84,7 @@ class RequestContext
/**
* Gets the base URL.
*
* @return string The base URL
* @return string
*/
public function getBaseUrl()
{
@@ -87,13 +94,11 @@ class RequestContext
/**
* Sets the base URL.
*
* @param string $baseUrl The base URL
*
* @return $this
*/
public function setBaseUrl($baseUrl)
public function setBaseUrl(string $baseUrl)
{
$this->baseUrl = $baseUrl;
$this->baseUrl = rtrim($baseUrl, '/');
return $this;
}
@@ -101,7 +106,7 @@ class RequestContext
/**
* Gets the path info.
*
* @return string The path info
* @return string
*/
public function getPathInfo()
{
@@ -111,11 +116,9 @@ class RequestContext
/**
* Sets the path info.
*
* @param string $pathInfo The path info
*
* @return $this
*/
public function setPathInfo($pathInfo)
public function setPathInfo(string $pathInfo)
{
$this->pathInfo = $pathInfo;
@@ -127,7 +130,7 @@ class RequestContext
*
* The method is always an uppercased string.
*
* @return string The HTTP method
* @return string
*/
public function getMethod()
{
@@ -137,11 +140,9 @@ class RequestContext
/**
* Sets the HTTP method.
*
* @param string $method The HTTP method
*
* @return $this
*/
public function setMethod($method)
public function setMethod(string $method)
{
$this->method = strtoupper($method);
@@ -153,7 +154,7 @@ class RequestContext
*
* The host is always lowercased because it must be treated case-insensitive.
*
* @return string The HTTP host
* @return string
*/
public function getHost()
{
@@ -163,11 +164,9 @@ class RequestContext
/**
* Sets the HTTP host.
*
* @param string $host The HTTP host
*
* @return $this
*/
public function setHost($host)
public function setHost(string $host)
{
$this->host = strtolower($host);
@@ -177,7 +176,7 @@ class RequestContext
/**
* Gets the HTTP scheme.
*
* @return string The HTTP scheme
* @return string
*/
public function getScheme()
{
@@ -187,11 +186,9 @@ class RequestContext
/**
* Sets the HTTP scheme.
*
* @param string $scheme The HTTP scheme
*
* @return $this
*/
public function setScheme($scheme)
public function setScheme(string $scheme)
{
$this->scheme = strtolower($scheme);
@@ -201,7 +198,7 @@ class RequestContext
/**
* Gets the HTTP port.
*
* @return int The HTTP port
* @return int
*/
public function getHttpPort()
{
@@ -211,13 +208,11 @@ class RequestContext
/**
* Sets the HTTP port.
*
* @param int $httpPort The HTTP port
*
* @return $this
*/
public function setHttpPort($httpPort)
public function setHttpPort(int $httpPort)
{
$this->httpPort = (int) $httpPort;
$this->httpPort = $httpPort;
return $this;
}
@@ -225,7 +220,7 @@ class RequestContext
/**
* Gets the HTTPS port.
*
* @return int The HTTPS port
* @return int
*/
public function getHttpsPort()
{
@@ -235,21 +230,19 @@ class RequestContext
/**
* Sets the HTTPS port.
*
* @param int $httpsPort The HTTPS port
*
* @return $this
*/
public function setHttpsPort($httpsPort)
public function setHttpsPort(int $httpsPort)
{
$this->httpsPort = (int) $httpsPort;
$this->httpsPort = $httpsPort;
return $this;
}
/**
* Gets the query string.
* Gets the query string without the "?".
*
* @return string The query string without the "?"
* @return string
*/
public function getQueryString()
{
@@ -259,11 +252,9 @@ class RequestContext
/**
* Sets the query string.
*
* @param string $queryString The query string (after "?")
*
* @return $this
*/
public function setQueryString($queryString)
public function setQueryString(?string $queryString)
{
// string cast to be fault-tolerant, accepting null
$this->queryString = (string) $queryString;
@@ -274,7 +265,7 @@ class RequestContext
/**
* Returns the parameters.
*
* @return array The parameters
* @return array
*/
public function getParameters()
{
@@ -298,23 +289,19 @@ class RequestContext
/**
* Gets a parameter value.
*
* @param string $name A parameter name
*
* @return mixed The parameter value or null if nonexistent
* @return mixed
*/
public function getParameter($name)
public function getParameter(string $name)
{
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
return $this->parameters[$name] ?? null;
}
/**
* Checks if a parameter value is set for the given parameter.
*
* @param string $name A parameter name
*
* @return bool True if the parameter value is set, false otherwise
* @return bool
*/
public function hasParameter($name)
public function hasParameter(string $name)
{
return \array_key_exists($name, $this->parameters);
}
@@ -322,15 +309,19 @@ class RequestContext
/**
* Sets a parameter value.
*
* @param string $name A parameter name
* @param mixed $parameter The parameter value
* @param mixed $parameter The parameter value
*
* @return $this
*/
public function setParameter($name, $parameter)
public function setParameter(string $name, $parameter)
{
$this->parameters[$name] = $parameter;
return $this;
}
public function isSecure(): bool
{
return 'https' === $this->scheme;
}
}