Skip to content

Commit c0a2415

Browse files
Merge branch '6.4' into 7.3
* 6.4: [Console] Fix signal handlers not being cleared after command termination [HttpFoundation] Fix RequestTest insulation ReflectionMethod::setAccessible() is no-op since PHP 8.1
2 parents 90804bb + 716e385 commit c0a2415

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

AcceptHeader.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,15 @@ public function __construct(array $items)
4646
*/
4747
public static function fromString(?string $headerValue): self
4848
{
49-
$parts = HeaderUtils::split($headerValue ?? '', ',;=');
49+
$items = [];
50+
foreach (HeaderUtils::split($headerValue ?? '', ',;=') as $i => $parts) {
51+
$part = array_shift($parts);
52+
$item = new AcceptHeaderItem($part[0], HeaderUtils::combine($parts));
5053

51-
return new self(array_map(function ($subParts) {
52-
static $index = 0;
53-
$part = array_shift($subParts);
54-
$attributes = HeaderUtils::combine($subParts);
55-
56-
$item = new AcceptHeaderItem($part[0], $attributes);
57-
$item->setIndex($index++);
54+
$items[] = $item->setIndex($i);
55+
}
5856

59-
return $item;
60-
}, $parts));
57+
return new self($items);
6158
}
6259

6360
/**
@@ -95,10 +92,11 @@ public function get(string $value): ?AcceptHeaderItem
9592
return null;
9693
}
9794

98-
usort($candidates, fn ($a, $b) =>
99-
$this->getSpecificity($b, $queryItem) <=> $this->getSpecificity($a, $queryItem) // Descending specificity
100-
?: $b->getQuality() <=> $a->getQuality() // Descending quality
101-
?: $a->getIndex() <=> $b->getIndex() // Ascending index (stability)
95+
usort(
96+
$candidates,
97+
fn ($a, $b) => $this->getSpecificity($b, $queryItem) <=> $this->getSpecificity($a, $queryItem) // Descending specificity
98+
?: $b->getQuality() <=> $a->getQuality() // Descending quality
99+
?: $a->getIndex() <=> $b->getIndex() // Ascending index (stability)
102100
);
103101

104102
return reset($candidates);

Tests/Fixtures/response-functional/invalid_cookie_name.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
try {
88
$r->headers->setCookie(new Cookie('Hello + world', 'hodor', 0, null, null, null, false, true));
9-
} catch (\InvalidArgumentException $e) {
9+
} catch (InvalidArgumentException $e) {
1010
echo $e->getMessage();
1111
}

Tests/RequestTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ protected function tearDown(): void
2929
{
3030
Request::setTrustedProxies([], -1);
3131
Request::setTrustedHosts([]);
32+
Request::setFactory(null);
33+
\Closure::bind(static fn () => self::$formats = null, null, Request::class)();
3234
}
3335

3436
public function testInitialize()

0 commit comments

Comments
 (0)