Skip to content

Commit 76adb4a

Browse files
committed
CS Fixer
1 parent eff3069 commit 76adb4a

File tree

2 files changed

+166
-166
lines changed

2 files changed

+166
-166
lines changed

src/Symfony/Component/HttpKernel/HttpCache/ResponseCacheStrategy.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
2727
/**
2828
* Cache-Control headers that are sent to the final response if they appear in ANY of the responses.
2929
*/
30-
private static $overrideDirectives = array('private', 'no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate');
30+
private static $overrideDirectives = ['private', 'no-cache', 'no-store', 'no-transform', 'must-revalidate', 'proxy-revalidate'];
3131

3232
/**
3333
* Cache-Control headers that are sent to the final response if they appear in ALL of the responses.
3434
*/
35-
private static $inheritDirectives = array('public', 'immutable');
35+
private static $inheritDirectives = ['public', 'immutable'];
3636

3737
private $embeddedResponses = 0;
3838
private $isNotCacheableResponseEmbedded = false;
3939
private $age = 0;
40-
private $flagDirectives = array(
40+
private $flagDirectives = [
4141
'no-cache' => null,
4242
'no-store' => null,
4343
'no-transform' => null,
@@ -46,12 +46,12 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
4646
'public' => null,
4747
'private' => null,
4848
'immutable' => null,
49-
);
50-
private $ageDirectives = array(
49+
];
50+
private $ageDirectives = [
5151
'max-age' => null,
5252
's-maxage' => null,
5353
'expires' => null,
54-
);
54+
];
5555

5656
/**
5757
* {@inheritdoc}
@@ -147,7 +147,7 @@ public function update(Response $response)
147147

148148
if (\is_numeric($this->ageDirectives['expires'])) {
149149
$date = clone $response->getDate();
150-
$date->modify('+'.($this->ageDirectives['expires']+$this->age).' seconds');
150+
$date->modify('+'.($this->ageDirectives['expires'] + $this->age).' seconds');
151151
$response->setExpires($date);
152152
}
153153
}
@@ -171,7 +171,7 @@ private function willMakeFinalResponseUncacheable(Response $response)
171171

172172
// Last-Modified and Etag headers cannot be merged, they render the response uncacheable
173173
// by default (except if the response also has max-age etc.).
174-
if (\in_array($response->getStatusCode(), array(200, 203, 300, 301, 410))
174+
if (\in_array($response->getStatusCode(), [200, 203, 300, 301, 410])
175175
&& null === $response->getLastModified()
176176
&& null === $response->getEtag()
177177
) {
@@ -181,7 +181,7 @@ private function willMakeFinalResponseUncacheable(Response $response)
181181
// RFC2616: A response received with any other status code (e.g. status codes 302 and 307)
182182
// MUST NOT be returned in a reply to a subsequent request unless there are
183183
// cache-control directives or another header(s) that explicitly allow it.
184-
$cacheControl = array('max-age', 's-maxage', 'must-revalidate', 'proxy-revalidate', 'public', 'private');
184+
$cacheControl = ['max-age', 's-maxage', 'must-revalidate', 'proxy-revalidate', 'public', 'private'];
185185
foreach ($cacheControl as $key) {
186186
if ($response->headers->hasCacheControlDirective($key)) {
187187
return false;

src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php

Lines changed: 157 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ public function testCacheControlMerging(array $expects, array $master, array $su
289289
$cacheStrategy->update($response);
290290

291291
foreach ($expects as $key => $value) {
292-
if ($key === 'expires') {
292+
if ('expires' === $key) {
293293
$this->assertSame($value, $response->getExpires()->format('U') - $response->getDate()->format('U'));
294-
} else if ($key === 'age') {
294+
} elseif ('age' === $key) {
295295
$this->assertSame($value, $response->getAge());
296296
} elseif (true === $value) {
297297
$this->assertTrue($response->headers->hasCacheControlDirective($key), sprintf('Cache-Control header must have "%s" flag', $key));
@@ -308,160 +308,160 @@ public function testCacheControlMerging(array $expects, array $master, array $su
308308

309309
public function cacheControlMergingProvider()
310310
{
311-
yield 'result is public if all responses are public' => array(
312-
array('private' => false, 'public' => true),
313-
array('public' => true),
314-
array(
315-
array('public' => true),
316-
),
317-
);
318-
319-
yield 'result is private by default' => array(
320-
array('private' => true, 'public' => false),
321-
array('public' => true),
322-
array(
323-
array(),
324-
),
325-
);
326-
327-
yield 'combines public and private responses' => array(
328-
array('must-revalidate' => false, 'private' => true, 'public' => false),
329-
array('public' => true),
330-
array(
331-
array('private' => true),
332-
),
333-
);
334-
335-
yield 'inherits no-cache from surrogates' => array(
336-
array('no-cache' => true, 'public' => false),
337-
array('public' => true),
338-
array(
339-
array('no-cache' => true),
340-
),
341-
);
342-
343-
yield 'inherits no-store from surrogate' => array(
344-
array('no-store' => true, 'public' => false),
345-
array('public' => true),
346-
array(
347-
array('no-store' => true),
348-
),
349-
);
350-
351-
yield 'resolve to lowest possible max-age' => array(
352-
array('public' => false, 'private' => true, 's-maxage' => false, 'max-age' => '60'),
353-
array('public' => true, 'max-age' => 3600),
354-
array(
355-
array('private' => true, 'max-age' => 60),
356-
),
357-
);
358-
359-
yield 'resolves multiple max-age' => array(
360-
array('public' => false, 'private' => true, 's-maxage' => false, 'max-age' => '60'),
361-
array('private' => true, 'max-age' => 100),
362-
array(
363-
array('private' => true, 'max-age' => 3600),
364-
array('public' => true, 'max-age' => 60, 's-maxage' => 60),
365-
array('private' => true, 'max-age' => 60),
366-
),
367-
);
368-
369-
yield 'merge max-age and s-maxage' => array(
370-
array('public' => true, 's-maxage' => '60', 'max-age' => null),
371-
array('public' => true, 's-maxage' => 3600),
372-
array(
373-
array('public' => true, 'max-age' => 60),
374-
),
375-
);
376-
377-
yield 'result is private when combining private responses' => array(
378-
array('no-cache' => false, 'must-revalidate' => false, 'private' => true),
379-
array('s-maxage' => 60, 'private' => true),
380-
array(
381-
array('s-maxage' => 60, 'private' => true),
382-
),
383-
);
384-
385-
yield 'result can have s-maxage and max-age' => array(
386-
array('public' => true, 'private' => false, 's-maxage' => '60', 'max-age' => '30'),
387-
array('s-maxage' => 100, 'max-age' => 2000),
388-
array(
389-
array('s-maxage' => 1000, 'max-age' => 30),
390-
array('s-maxage' => 500, 'max-age' => 500),
391-
array('s-maxage' => 60, 'max-age' => 1000),
392-
),
393-
);
394-
395-
yield 'does not set headers without value' => array(
396-
array('max-age' => null, 's-maxage' => null, 'public' => null),
397-
array('private' => true),
398-
array(
399-
array('private' => true),
400-
),
401-
);
402-
403-
yield 'max-age 0 is sent to the client' => array(
404-
array('private' => true, 'max-age' => '0'),
405-
array('max-age' => 0, 'private' => true),
406-
array(
407-
array('max-age' => 60, 'private' => true),
408-
),
409-
);
410-
411-
yield 'max-age is relative to age' => array(
412-
array('max-age' => '240', 'age' => 60),
413-
array('max-age' => 180),
414-
array(
415-
array('max-age' => 600, 'age' => 60),
416-
),
417-
);
418-
419-
yield 'retains lowest age of all responses' => array(
420-
array('max-age' => '160', 'age' => 60),
421-
array('max-age' => 600, 'age' => 60),
422-
array(
423-
array('max-age' => 120, 'age' => 20),
424-
),
425-
);
426-
427-
yield 'max-age can be less than age, essentially expiring the response' => array(
428-
array('age' => 120, 'max-age' => '90'),
429-
array('max-age' => 90, 'age' => 120),
430-
array(
431-
array('max-age' => 120, 'age' => 60),
432-
),
433-
);
434-
435-
yield 'max-age is 0 regardless of age' => array(
436-
array('max-age' => '0'),
437-
array('max-age' => 60),
438-
array(
439-
array('max-age' => 0, 'age' => 60),
440-
),
441-
);
442-
443-
yield 'max-age is not negative' => array(
444-
array('max-age' => '0'),
445-
array('max-age' => 0),
446-
array(
447-
array('max-age' => 0, 'age' => 60),
448-
),
449-
);
450-
451-
yield 'calculates lowest Expires header' => array(
452-
array('expires' => 60),
453-
array('expires' => 60),
454-
array(
455-
array('expires' => 120),
456-
),
457-
);
458-
459-
yield 'calculates Expires header relative to age' => array(
460-
array('expires' => 210, 'age' => 120),
461-
array('expires' => 90),
462-
array(
463-
array('expires' => 600, 'age' => '120'),
464-
),
465-
);
311+
yield 'result is public if all responses are public' => [
312+
['private' => false, 'public' => true],
313+
['public' => true],
314+
[
315+
['public' => true],
316+
],
317+
];
318+
319+
yield 'result is private by default' => [
320+
['private' => true, 'public' => false],
321+
['public' => true],
322+
[
323+
[],
324+
],
325+
];
326+
327+
yield 'combines public and private responses' => [
328+
['must-revalidate' => false, 'private' => true, 'public' => false],
329+
['public' => true],
330+
[
331+
['private' => true],
332+
],
333+
];
334+
335+
yield 'inherits no-cache from surrogates' => [
336+
['no-cache' => true, 'public' => false],
337+
['public' => true],
338+
[
339+
['no-cache' => true],
340+
],
341+
];
342+
343+
yield 'inherits no-store from surrogate' => [
344+
['no-store' => true, 'public' => false],
345+
['public' => true],
346+
[
347+
['no-store' => true],
348+
],
349+
];
350+
351+
yield 'resolve to lowest possible max-age' => [
352+
['public' => false, 'private' => true, 's-maxage' => false, 'max-age' => '60'],
353+
['public' => true, 'max-age' => 3600],
354+
[
355+
['private' => true, 'max-age' => 60],
356+
],
357+
];
358+
359+
yield 'resolves multiple max-age' => [
360+
['public' => false, 'private' => true, 's-maxage' => false, 'max-age' => '60'],
361+
['private' => true, 'max-age' => 100],
362+
[
363+
['private' => true, 'max-age' => 3600],
364+
['public' => true, 'max-age' => 60, 's-maxage' => 60],
365+
['private' => true, 'max-age' => 60],
366+
],
367+
];
368+
369+
yield 'merge max-age and s-maxage' => [
370+
['public' => true, 's-maxage' => '60', 'max-age' => null],
371+
['public' => true, 's-maxage' => 3600],
372+
[
373+
['public' => true, 'max-age' => 60],
374+
],
375+
];
376+
377+
yield 'result is private when combining private responses' => [
378+
['no-cache' => false, 'must-revalidate' => false, 'private' => true],
379+
['s-maxage' => 60, 'private' => true],
380+
[
381+
['s-maxage' => 60, 'private' => true],
382+
],
383+
];
384+
385+
yield 'result can have s-maxage and max-age' => [
386+
['public' => true, 'private' => false, 's-maxage' => '60', 'max-age' => '30'],
387+
['s-maxage' => 100, 'max-age' => 2000],
388+
[
389+
['s-maxage' => 1000, 'max-age' => 30],
390+
['s-maxage' => 500, 'max-age' => 500],
391+
['s-maxage' => 60, 'max-age' => 1000],
392+
],
393+
];
394+
395+
yield 'does not set headers without value' => [
396+
['max-age' => null, 's-maxage' => null, 'public' => null],
397+
['private' => true],
398+
[
399+
['private' => true],
400+
],
401+
];
402+
403+
yield 'max-age 0 is sent to the client' => [
404+
['private' => true, 'max-age' => '0'],
405+
['max-age' => 0, 'private' => true],
406+
[
407+
['max-age' => 60, 'private' => true],
408+
],
409+
];
410+
411+
yield 'max-age is relative to age' => [
412+
['max-age' => '240', 'age' => 60],
413+
['max-age' => 180],
414+
[
415+
['max-age' => 600, 'age' => 60],
416+
],
417+
];
418+
419+
yield 'retains lowest age of all responses' => [
420+
['max-age' => '160', 'age' => 60],
421+
['max-age' => 600, 'age' => 60],
422+
[
423+
['max-age' => 120, 'age' => 20],
424+
],
425+
];
426+
427+
yield 'max-age can be less than age, essentially expiring the response' => [
428+
['age' => 120, 'max-age' => '90'],
429+
['max-age' => 90, 'age' => 120],
430+
[
431+
['max-age' => 120, 'age' => 60],
432+
],
433+
];
434+
435+
yield 'max-age is 0 regardless of age' => [
436+
['max-age' => '0'],
437+
['max-age' => 60],
438+
[
439+
['max-age' => 0, 'age' => 60],
440+
],
441+
];
442+
443+
yield 'max-age is not negative' => [
444+
['max-age' => '0'],
445+
['max-age' => 0],
446+
[
447+
['max-age' => 0, 'age' => 60],
448+
],
449+
];
450+
451+
yield 'calculates lowest Expires header' => [
452+
['expires' => 60],
453+
['expires' => 60],
454+
[
455+
['expires' => 120],
456+
],
457+
];
458+
459+
yield 'calculates Expires header relative to age' => [
460+
['expires' => 210, 'age' => 120],
461+
['expires' => 90],
462+
[
463+
['expires' => 600, 'age' => '120'],
464+
],
465+
];
466466
}
467467
}

0 commit comments

Comments
 (0)