Skip to content

Commit 19f925f

Browse files
Merge branch '7.4' into 8.0
* 7.4: fix merge [HttpFoundation] Fix tests [JsonStreamer] Finish #62063 upmerge [Console] Fix signal handlers not being cleared after command termination [HttpFoundation] Fix RequestTest insulation ReflectionMethod::setAccessible() is no-op since PHP 8.1 CS fix fix merge
2 parents d3ad402 + 769c172 commit 19f925f

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ protected function tearDown(): void
3131
Request::setTrustedProxies([], -1);
3232
Request::setTrustedHosts([]);
3333
Request::setAllowedHttpMethodOverride(null);
34+
Request::setFactory(null);
35+
\Closure::bind(static fn () => self::$formats = null, null, Request::class)();
3436
}
3537

3638
public function testInitialize()
@@ -583,11 +585,11 @@ public static function getFormatToMimeTypeMapProvider()
583585
['form', ['application/x-www-form-urlencoded', 'multipart/form-data']],
584586
['rss', ['application/rss+xml']],
585587
['soap', ['application/soap+xml']],
586-
['html', ['application/xhtml+xml']],
588+
['html', ['text/html', 'application/xhtml+xml']],
587589
['problem', ['application/problem+json']],
588590
['hal', ['application/hal+json', 'application/hal+xml']],
589591
['jsonapi', ['application/vnd.api+json']],
590-
['yaml', ['application/x-yaml', 'text/yaml']],
592+
['yaml', ['text/yaml', 'application/x-yaml']],
591593
['wbxml', ['application/vnd.wap.wbxml']],
592594
];
593595
}

0 commit comments

Comments
 (0)