diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index fe35832f87ed0..ddfd1826e46cd 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -949,7 +949,7 @@ public function setEtag(string $etag = null, bool $weak = false): object */ 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 73a6936807215..2dea5c2b2aecf 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php @@ -672,6 +672,12 @@ public function testSetCache() $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()
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: