8000 minor #36379 Fix constant accessor (driesvints) · symfony/symfony@aa44db0 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa44db0

Browse files
committed
minor #36379 Fix constant accessor (driesvints)
This PR was squashed before being merged into the 5.1-dev branch. Discussion ---------- Fix constant accessor | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Because HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES is private, using static will fail for any classes extending the Response class. HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES is already properly using self a bit lower so we should do the same thing here. Introduced in #35748 Commits ------- 633ff5b Fix constant accessor
2 parents 2d6327f + 633ff5b commit aa44db0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Symfony/Component/HttpFoundation/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ public function setEtag(string $etag = null, bool $weak = false): object
949949
*/
950950
public function setCache(array $options): object
951951
{
952-
if ($diff = array_diff(array_keys($options), array_keys(static::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) {
952+
if ($diff = array_diff(array_keys($options), array_keys(self::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) {
953953
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff)));
954954
}
955955

src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,12 @@ public function testSetCache()
672672

673673
$this->assertFalse($response->headers->hasCacheControlDirective(str_replace('_', '-', $directive)));
674674
}
675+
676+
$response = new DefaultResponse();
677+
678+
$options = ['etag' => '"whatever"'];
679+
$response->setCache($options);
680+
$this->assertSame($response->getEtag(), '"whatever"');
675681
}
676682

677683
public function testSendContent()

0 commit comments

Comments
 (0)
0