@@ -30,15 +30,13 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
30
30
{
31
31
/**
32
32
* Cache-Control headers that are sent to the final response if they appear in ANY of the responses.
33
- * @var array
34
33
*/
35
- private static $ overrideDirectives = [ 'no-cache ' , 'no-store ' , 'no-transform ' , 'must-revalidate ' , 'proxy-revalidate ' ] ;
34
+ private static $ overrideDirectives = array ( 'no-cache ' , 'no-store ' , 'no-transform ' , 'must-revalidate ' , 'proxy-revalidate ' ) ;
36
35
37
36
/**
38
37
* Cache-Control headers that are sent to the final response if the appear in ALL of the responses.
39
- * @var array
40
38
*/
41
- private static $ inheritDirectives = [ 'public ' , 'private ' , 'immutable ' ] ;
39
+ private static $ inheritDirectives = array ( 'public ' , 'private ' , 'immutable ' ) ;
42
40
43
41
private $ embeddedResponses = 0 ;
44
42
private $ isNotCacheableResponseEmbedded = false ;
@@ -90,8 +88,8 @@ public function add(Response $response)
90
88
$ this ->storeRelativeAgeDirective ('s-maxage ' , $ response ->headers ->getCacheControlDirective ('s-maxage ' ), $ age );
91
89
92
90
$ expires = $ response ->getExpires ();
93
- $ expires = null === $ expires ? null : $ expires ->format ('U ' ) - $ response ->getDate ()->format ('U ' );
94
- $ this ->storeRelativeAgeDirective ('expires ' , $ expires < 0 ? null : $ expires , 0 );
91
+ $ expires = null !== $ expires ? $ expires ->format ('U ' ) - $ response ->getDate ()->format ('U ' ) : null ;
92
+ $ this ->storeRelativeAgeDirective ('expires ' , $ expires >= 0 ? $ expires : null , 0 );
95
93
}
96
94
97
95
/**
@@ -146,8 +144,6 @@ public function update(Response $response)
146
144
*
147
145
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4
148
146
*
149
- * @param Response $response
150
- *
151
147
* @return bool
152
148
*/
153
149
private function isUncacheable (Response $ response )
@@ -165,7 +161,7 @@ private function isUncacheable(Response $response)
165
161
// A response received with any other status code (e.g. status codes 302 and 307)
166
162
// MUST NOT be returned in a reply to a subsequent request unless there are
167
163
// cache-control directives or another header(s) that explicitly allow it.
168
- $ cacheControl = [ 'max-age ' , 's-maxage ' , 'must-revalidate ' , 'proxy-revalidate ' , 'public ' , 'private ' , 'must-revalidate ' ] ;
164
+ $ cacheControl = array ( 'max-age ' , 's-maxage ' , 'must-revalidate ' , 'proxy-revalidate ' , 'public ' , 'private ' , 'must-revalidate ' ) ;
169
165
foreach ($ cacheControl as $ key ) {
170
166
if ($ response ->headers ->hasCacheControlDirective ($ key )) {
171
167
return false ;
@@ -194,7 +190,7 @@ private function storeRelativeAgeDirective($cacheKey, $value, $age)
194
190
195
191
if (false !== $ this ->ageDirectives [$ cacheKey ]) {
196
192
$ value = $ value - $ age ;
197
- $ this ->ageDirectives [$ cacheKey ] = null === $ this ->ageDirectives [$ cacheKey ] ? $ value : min ($ this ->ageDirectives [$ cacheKey ], $ value );
193
+ $ this ->ageDirectives [$ cacheKey ] = null !== $ this ->ageDirectives [$ cacheKey ] ? min ($ this ->ageDirectives [$ cacheKey ], $ value ) : $ value ;
198
194
}
199
195
}
200
196
}
0 commit comments