Update dependencies

This commit is contained in:
Chris Hunt
2024-02-16 21:36:54 +00:00
parent 22d7a59e59
commit d52ae0d3c3
9569 changed files with 460443 additions and 282416 deletions

View File

@@ -27,12 +27,9 @@ class AcceptHeader
/**
* @var AcceptHeaderItem[]
*/
private $items = [];
private array $items = [];
/**
* @var bool
*/
private $sorted = true;
private bool $sorted = true;
/**
* @param AcceptHeaderItem[] $items
@@ -46,16 +43,13 @@ class AcceptHeader
/**
* Builds an AcceptHeader instance from a string.
*
* @return self
*/
public static function fromString(?string $headerValue)
public static function fromString(?string $headerValue): self
{
$index = 0;
$parts = HeaderUtils::split($headerValue ?? '', ',;=');
return new self(array_map(function ($subParts) use (&$index) {
return new self(array_map(function ($subParts) {
static $index = 0;
$part = array_shift($subParts);
$attributes = HeaderUtils::combine($subParts);
@@ -68,30 +62,24 @@ class AcceptHeader
/**
* Returns header value's string representation.
*
* @return string
*/
public function __toString()
public function __toString(): string
{
return implode(',', $this->items);
}
/**
* Tests if header has given value.
*
* @return bool
*/
public function has(string $value)
public function has(string $value): bool
{
return isset($this->items[$value]);
}
/**
* Returns given value's item, if exists.
*
* @return AcceptHeaderItem|null
*/
public function get(string $value)
public function get(string $value): ?AcceptHeaderItem
{
return $this->items[$value] ?? $this->items[explode('/', $value)[0].'/*'] ?? $this->items['*/*'] ?? $this->items['*'] ?? null;
}
@@ -101,7 +89,7 @@ class AcceptHeader
*
* @return $this
*/
public function add(AcceptHeaderItem $item)
public function add(AcceptHeaderItem $item): static
{
$this->items[$item->getValue()] = $item;
$this->sorted = false;
@@ -114,7 +102,7 @@ class AcceptHeader
*
* @return AcceptHeaderItem[]
*/
public function all()
public function all(): array
{
$this->sort();
@@ -123,26 +111,20 @@ class AcceptHeader
/**
* Filters items on their value using given regex.
*
* @return self
*/
public function filter(string $pattern)
public function filter(string $pattern): self
{
return new self(array_filter($this->items, function (AcceptHeaderItem $item) use ($pattern) {
return preg_match($pattern, $item->getValue());
}));
return new self(array_filter($this->items, fn (AcceptHeaderItem $item) => preg_match($pattern, $item->getValue())));
}
/**
* Returns first item.
*
* @return AcceptHeaderItem|null
*/
public function first()
public function first(): ?AcceptHeaderItem
{
$this->sort();
return !empty($this->items) ? reset($this->items) : null;
return $this->items ? reset($this->items) : null;
}
/**