upgraded dependencies
This commit is contained in:
97
vendor/symfony/routing/RequestContext.php
vendored
97
vendor/symfony/routing/RequestContext.php
vendored
@@ -45,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.
|
||||
*
|
||||
@@ -67,7 +84,7 @@ class RequestContext
|
||||
/**
|
||||
* Gets the base URL.
|
||||
*
|
||||
* @return string The base URL
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseUrl()
|
||||
{
|
||||
@@ -77,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;
|
||||
}
|
||||
@@ -91,7 +106,7 @@ class RequestContext
|
||||
/**
|
||||
* Gets the path info.
|
||||
*
|
||||
* @return string The path info
|
||||
* @return string
|
||||
*/
|
||||
public function getPathInfo()
|
||||
{
|
||||
@@ -101,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;
|
||||
|
||||
@@ -117,7 +130,7 @@ class RequestContext
|
||||
*
|
||||
* The method is always an uppercased string.
|
||||
*
|
||||
* @return string The HTTP method
|
||||
* @return string
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
@@ -127,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);
|
||||
|
||||
@@ -143,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()
|
||||
{
|
||||
@@ -153,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);
|
||||
|
||||
@@ -167,7 +176,7 @@ class RequestContext
|
||||
/**
|
||||
* Gets the HTTP scheme.
|
||||
*
|
||||
* @return string The HTTP scheme
|
||||
* @return string
|
||||
*/
|
||||
public function getScheme()
|
||||
{
|
||||
@@ -177,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);
|
||||
|
||||
@@ -191,7 +198,7 @@ class RequestContext
|
||||
/**
|
||||
* Gets the HTTP port.
|
||||
*
|
||||
* @return int The HTTP port
|
||||
* @return int
|
||||
*/
|
||||
public function getHttpPort()
|
||||
{
|
||||
@@ -201,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;
|
||||
}
|
||||
@@ -215,7 +220,7 @@ class RequestContext
|
||||
/**
|
||||
* Gets the HTTPS port.
|
||||
*
|
||||
* @return int The HTTPS port
|
||||
* @return int
|
||||
*/
|
||||
public function getHttpsPort()
|
||||
{
|
||||
@@ -225,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()
|
||||
{
|
||||
@@ -249,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;
|
||||
@@ -264,7 +265,7 @@ class RequestContext
|
||||
/**
|
||||
* Returns the parameters.
|
||||
*
|
||||
* @return array The parameters
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
@@ -288,11 +289,9 @@ 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 $this->parameters[$name] ?? null;
|
||||
}
|
||||
@@ -300,11 +299,9 @@ class RequestContext
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
@@ -312,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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user