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

@@ -15,12 +15,17 @@ namespace Symfony\Component\HttpFoundation;
* HeaderBag is a container for HTTP headers.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @implements \IteratorAggregate<string, list<string|null>>
*/
class HeaderBag implements \IteratorAggregate, \Countable
{
protected const UPPER = '_ABCDEFGHIJKLMNOPQRSTUVWXYZ';
protected const LOWER = '-abcdefghijklmnopqrstuvwxyz';
/**
* @var array<string, list<string|null>>
*/
protected $headers = [];
protected $cacheControl = [];
@@ -34,7 +39,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns the headers as a string.
*
* @return string The headers
* @return string
*/
public function __toString()
{
@@ -60,11 +65,11 @@ class HeaderBag implements \IteratorAggregate, \Countable
*
* @param string|null $key The name of the headers to return or null to get them all
*
* @return array An array of headers
* @return array<string, array<int, string|null>>|array<int, string|null>
*/
public function all(/* string $key = null */)
public function all(string $key = null)
{
if (1 <= \func_num_args() && null !== $key = func_get_arg(0)) {
if (null !== $key) {
return $this->headers[strtr($key, self::UPPER, self::LOWER)] ?? [];
}
@@ -74,7 +79,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns the parameter keys.
*
* @return array An array of parameter keys
* @return string[]
*/
public function keys()
{
@@ -101,23 +106,13 @@ class HeaderBag implements \IteratorAggregate, \Countable
}
/**
* Returns a header value by name.
* Returns the first header by name or the default one.
*
* @param string $key The header name
* @param string|null $default The default value
*
* @return string|null The first header value or default value
* @return string|null
*/
public function get($key, $default = null)
public function get(string $key, string $default = null)
{
$headers = $this->all((string) $key);
if (2 < \func_num_args()) {
@trigger_error(sprintf('Passing a third argument to "%s()" is deprecated since Symfony 4.4, use method "all()" instead', __METHOD__), \E_USER_DEPRECATED);
if (!func_get_arg(2)) {
return $headers;
}
}
$headers = $this->all($key);
if (!$headers) {
return $default;
@@ -133,11 +128,10 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Sets a header by name.
*
* @param string $key The key
* @param string|string[]|null $values The value or an array of values
* @param bool $replace Whether to replace the actual value or not (true by default)
*/
public function set($key, $values, $replace = true)
public function set(string $key, $values, bool $replace = true)
{
$key = strtr($key, self::UPPER, self::LOWER);
@@ -165,11 +159,9 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns true if the HTTP header is defined.
*
* @param string $key The HTTP header
*
* @return bool true if the parameter exists, false otherwise
* @return bool
*/
public function has($key)
public function has(string $key)
{
return \array_key_exists(strtr($key, self::UPPER, self::LOWER), $this->all());
}
@@ -177,22 +169,17 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns true if the given HTTP header contains the given value.
*
* @param string $key The HTTP header name
* @param string $value The HTTP value
*
* @return bool true if the value is contained in the header, false otherwise
* @return bool
*/
public function contains($key, $value)
public function contains(string $key, string $value)
{
return \in_array($value, $this->all((string) $key));
return \in_array($value, $this->all($key));
}
/**
* Removes a header.
*
* @param string $key The HTTP header name
*/
public function remove($key)
public function remove(string $key)
{
$key = strtr($key, self::UPPER, self::LOWER);
@@ -206,13 +193,11 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns the HTTP header value converted to a date.
*
* @param string $key The parameter key
*
* @return \DateTimeInterface|null The parsed DateTime or the default value if the header does not exist
* @return \DateTimeInterface|null
*
* @throws \RuntimeException When the HTTP header is not parseable
*/
public function getDate($key, \DateTime $default = null)
public function getDate(string $key, \DateTime $default = null)
{
if (null === $value = $this->get($key)) {
return $default;
@@ -228,10 +213,9 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Adds a custom Cache-Control directive.
*
* @param string $key The Cache-Control directive name
* @param bool|string $value The Cache-Control directive value
*/
public function addCacheControlDirective($key, $value = true)
public function addCacheControlDirective(string $key, $value = true)
{
$this->cacheControl[$key] = $value;
@@ -241,11 +225,9 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns true if the Cache-Control directive is defined.
*
* @param string $key The Cache-Control directive
*
* @return bool true if the directive exists, false otherwise
* @return bool
*/
public function hasCacheControlDirective($key)
public function hasCacheControlDirective(string $key)
{
return \array_key_exists($key, $this->cacheControl);
}
@@ -253,21 +235,17 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns a Cache-Control directive value by name.
*
* @param string $key The directive name
*
* @return bool|string|null The directive value if defined, null otherwise
* @return bool|string|null
*/
public function getCacheControlDirective($key)
public function getCacheControlDirective(string $key)
{
return $this->cacheControl[$key] ?? null;
}
/**
* Removes a Cache-Control directive.
*
* @param string $key The Cache-Control directive
*/
public function removeCacheControlDirective($key)
public function removeCacheControlDirective(string $key)
{
unset($this->cacheControl[$key]);
@@ -277,7 +255,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns an iterator for headers.
*
* @return \ArrayIterator An \ArrayIterator instance
* @return \ArrayIterator<string, list<string|null>>
*/
#[\ReturnTypeWillChange]
public function getIterator()
@@ -288,7 +266,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Returns the number of headers.
*
* @return int The number of headers
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
@@ -306,11 +284,9 @@ class HeaderBag implements \IteratorAggregate, \Countable
/**
* Parses a Cache-Control HTTP header.
*
* @param string $header The value of the Cache-Control HTTP header
*
* @return array An array representing the attribute values
* @return array
*/
protected function parseCacheControl($header)
protected function parseCacheControl(string $header)
{
$parts = HeaderUtils::split($header, ',=');