upgraded dependencies

This commit is contained in:
RafficMohammed
2023-01-08 01:59:16 +05:30
parent 51056e3aad
commit f9ae387337
6895 changed files with 133617 additions and 178680 deletions

View File

@@ -78,12 +78,9 @@ class Route implements \Serializable
}
/**
* @return string
*
* @internal since Symfony 4.3
* @final since Symfony 4.3
* @internal
*/
public function serialize()
final public function serialize(): string
{
return serialize($this->__serialize());
}
@@ -107,16 +104,15 @@ class Route implements \Serializable
}
/**
* @internal since Symfony 4.3
* @final since Symfony 4.3
* @internal
*/
public function unserialize($serialized)
final public function unserialize($serialized)
{
$this->__unserialize(unserialize($serialized));
}
/**
* @return string The path pattern
* @return string
*/
public function getPath()
{
@@ -124,26 +120,11 @@ class Route implements \Serializable
}
/**
* Sets the pattern for the path.
*
* @param string $pattern The path pattern
*
* @return $this
*/
public function setPath($pattern)
public function setPath(string $pattern)
{
if (false !== strpbrk($pattern, '?<')) {
$pattern = preg_replace_callback('#\{(!?)(\w++)(<.*?>)?(\?[^\}]*+)?\}#', function ($m) {
if (isset($m[4][0])) {
$this->setDefault($m[2], '?' !== $m[4] ? substr($m[4], 1) : null);
}
if (isset($m[3][0])) {
$this->setRequirement($m[2], substr($m[3], 1, -1));
}
return '{'.$m[1].$m[2].'}';
}, $pattern);
}
$pattern = $this->extractInlineDefaultsAndRequirements($pattern);
// A pattern must start with a slash and must not have multiple slashes at the beginning because the
// generated path for this route would be confused with a network path, e.g. '//domain.com/path'.
@@ -154,7 +135,7 @@ class Route implements \Serializable
}
/**
* @return string The host pattern
* @return string
*/
public function getHost()
{
@@ -162,15 +143,11 @@ class Route implements \Serializable
}
/**
* Sets the pattern for the host.
*
* @param string $pattern The host pattern
*
* @return $this
*/
public function setHost($pattern)
public function setHost(?string $pattern)
{
$this->host = (string) $pattern;
$this->host = $this->extractInlineDefaultsAndRequirements((string) $pattern);
$this->compiled = null;
return $this;
@@ -180,7 +157,7 @@ class Route implements \Serializable
* Returns the lowercased schemes this route is restricted to.
* So an empty array means that any scheme is allowed.
*
* @return string[] The schemes
* @return string[]
*/
public function getSchemes()
{
@@ -206,11 +183,9 @@ class Route implements \Serializable
/**
* Checks if a scheme requirement has been set.
*
* @param string $scheme
*
* @return bool true if the scheme requirement exists, otherwise false
* @return bool
*/
public function hasScheme($scheme)
public function hasScheme(string $scheme)
{
return \in_array(strtolower($scheme), $this->schemes, true);
}
@@ -219,7 +194,7 @@ class Route implements \Serializable
* Returns the uppercased HTTP methods this route is restricted to.
* So an empty array means that any method is allowed.
*
* @return string[] The methods
* @return string[]
*/
public function getMethods()
{
@@ -243,7 +218,7 @@ class Route implements \Serializable
}
/**
* @return array The options
* @return array
*/
public function getOptions()
{
@@ -278,12 +253,11 @@ class Route implements \Serializable
/**
* Sets an option value.
*
* @param string $name An option name
* @param mixed $value The option value
* @param mixed $value The option value
*
* @return $this
*/
public function setOption($name, $value)
public function setOption(string $name, $value)
{
$this->options[$name] = $value;
$this->compiled = null;
@@ -292,31 +266,25 @@ class Route implements \Serializable
}
/**
* Get an option value.
* Returns the option value or null when not found.
*
* @param string $name An option name
*
* @return mixed The option value or null when not given
* @return mixed
*/
public function getOption($name)
public function getOption(string $name)
{
return $this->options[$name] ?? null;
}
/**
* Checks if an option has been set.
*
* @param string $name An option name
*
* @return bool true if the option is set, false otherwise
* @return bool
*/
public function hasOption($name)
public function hasOption(string $name)
{
return \array_key_exists($name, $this->options);
}
/**
* @return array The defaults
* @return array
*/
public function getDefaults()
{
@@ -351,25 +319,17 @@ class Route implements \Serializable
}
/**
* Gets a default value.
*
* @param string $name A variable name
*
* @return mixed The default value or null when not given
* @return mixed
*/
public function getDefault($name)
public function getDefault(string $name)
{
return $this->defaults[$name] ?? null;
}
/**
* Checks if a default value is set for the given variable.
*
* @param string $name A variable name
*
* @return bool true if the default value is set, false otherwise
* @return bool
*/
public function hasDefault($name)
public function hasDefault(string $name)
{
return \array_key_exists($name, $this->defaults);
}
@@ -377,12 +337,11 @@ class Route implements \Serializable
/**
* Sets a default value.
*
* @param string $name A variable name
* @param mixed $default The default value
* @param mixed $default The default value
*
* @return $this
*/
public function setDefault($name, $default)
public function setDefault(string $name, $default)
{
if ('_locale' === $name && $this->isLocalized()) {
return $this;
@@ -395,7 +354,7 @@ class Route implements \Serializable
}
/**
* @return array The requirements
* @return array
*/
public function getRequirements()
{
@@ -430,38 +389,25 @@ class Route implements \Serializable
}
/**
* Returns the requirement for the given key.
*
* @param string $key The key
*
* @return string|null The regex or null when not given
* @return string|null
*/
public function getRequirement($key)
public function getRequirement(string $key)
{
return $this->requirements[$key] ?? null;
}
/**
* Checks if a requirement is set for the given key.
*
* @param string $key A variable name
*
* @return bool true if a requirement is specified, false otherwise
* @return bool
*/
public function hasRequirement($key)
public function hasRequirement(string $key)
{
return \array_key_exists($key, $this->requirements);
}
/**
* Sets a requirement for the given key.
*
* @param string $key The key
* @param string $regex The regex
*
* @return $this
*/
public function setRequirement($key, $regex)
public function setRequirement(string $key, string $regex)
{
if ('_locale' === $key && $this->isLocalized()) {
return $this;
@@ -474,7 +420,7 @@ class Route implements \Serializable
}
/**
* @return string The condition
* @return string
*/
public function getCondition()
{
@@ -482,13 +428,9 @@ class Route implements \Serializable
}
/**
* Sets the condition.
*
* @param string $condition The condition
*
* @return $this
*/
public function setCondition($condition)
public function setCondition(?string $condition)
{
$this->condition = (string) $condition;
$this->compiled = null;
@@ -499,7 +441,7 @@ class Route implements \Serializable
/**
* Compiles the route.
*
* @return CompiledRoute A CompiledRoute instance
* @return CompiledRoute
*
* @throws \LogicException If the Route cannot be compiled because the
* path or host pattern is invalid
@@ -517,18 +459,38 @@ class Route implements \Serializable
return $this->compiled = $class::compile($this);
}
private function sanitizeRequirement(string $key, $regex)
private function extractInlineDefaultsAndRequirements(string $pattern): string
{
if (!\is_string($regex)) {
throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" must be a string.', $key));
if (false === strpbrk($pattern, '?<')) {
return $pattern;
}
if ('' !== $regex && '^' === $regex[0]) {
$regex = (string) substr($regex, 1); // returns false for a single character
return preg_replace_callback('#\{(!?)(\w++)(<.*?>)?(\?[^\}]*+)?\}#', function ($m) {
if (isset($m[4][0])) {
$this->setDefault($m[2], '?' !== $m[4] ? substr($m[4], 1) : null);
}
if (isset($m[3][0])) {
$this->setRequirement($m[2], substr($m[3], 1, -1));
}
return '{'.$m[1].$m[2].'}';
}, $pattern);
}
private function sanitizeRequirement(string $key, string $regex)
{
if ('' !== $regex) {
if ('^' === $regex[0]) {
$regex = substr($regex, 1);
} elseif (0 === strpos($regex, '\\A')) {
$regex = substr($regex, 2);
}
}
if (str_ends_with($regex, '$')) {
$regex = substr($regex, 0, -1);
} elseif (\strlen($regex) - 2 === strpos($regex, '\\z')) {
$regex = substr($regex, 0, -2);
}
if ('' === $regex) {
@@ -540,6 +502,6 @@ class Route implements \Serializable
private function isLocalized(): bool
{
return isset($this->defaults['_locale']) && isset($this->defaults['_canonical_route']) && ($this->requirements['_locale'] ?? null) === preg_quote($this->defaults['_locale'], RouteCompiler::REGEX_DELIMITER);
return isset($this->defaults['_locale']) && isset($this->defaults['_canonical_route']) && ($this->requirements['_locale'] ?? null) === preg_quote($this->defaults['_locale']);
}
}