diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index fe35832f87..ddfd1826e4 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -949,7 +949,7 @@ class Response */ public function setCache(array $options): object { - if ($diff = array_diff(array_keys($options), array_keys(static::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) { + if ($diff = array_diff(array_keys($options), array_keys(self::HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES))) { throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', $diff))); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 73a6936807..2dea5c2b2a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -672,6 +672,12 @@ class ResponseTest extends ResponseTestCase $this->assertFalse($response->headers->hasCacheControlDirective(str_replace('_', '-', $directive))); } + + $response = new DefaultResponse(); + + $options = ['etag' => '"whatever"']; + $response->setCache($options); + $this->assertSame($response->getEtag(), '"whatever"'); } public function testSendContent()