@@ -211,7 +211,7 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
211
211
// avoid throwing exception in ErrorChunk#__destruct()
212
212
$ chunk instanceof ErrorChunk && $ chunk ->didThrow (true );
213
213
$ context ->passthru ();
214
- $ context ->replaceResponse ($ this -> createGatewayTimeoutResponse ($ method , $ url , $ options ));
214
+ $ context ->replaceResponse (self :: createGatewayTimeoutResponse ($ method , $ url , $ options ));
215
215
216
216
return ;
217
217
}
@@ -222,15 +222,15 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
222
222
}
223
223
224
224
$ headers = $ context ->getHeaders ();
225
- $ cacheControl = $ this -> parseCacheControlHeader ($ headers ['cache-control ' ] ?? []);
225
+ $ cacheControl = self :: parseCacheControlHeader ($ headers ['cache-control ' ] ?? []);
226
226
227
227
if ($ chunk ->isFirst ()) {
228
228
$ statusCode = $ context ->getStatusCode ();
229
229
230
230
if (304 === $ statusCode && null !== $ freshness ) {
231
231
$ maxAge = $ this ->determineMaxAge ($ headers , $ cacheControl );
232
232
233
- $ cachedData ['expires_at ' ] = $ this -> calculateExpiresAt ($ maxAge );
233
+ $ cachedData ['expires_at ' ] = self :: calculateExpiresAt ($ maxAge );
234
234
$ cachedData ['stored_at ' ] = time ();
235
235
$ cachedData ['initial_age ' ] = (int ) ($ headers ['age ' ][0 ] ?? 0 );
236
236
$ cachedData ['headers ' ] = array_merge ($ cachedData ['headers ' ], array_diff_key ($ headers , self ::EXCLUDED_HEADERS ));
@@ -254,7 +254,7 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
254
254
255
255
if (Freshness::MustRevalidate === $ freshness ) {
256
256
$ context ->passthru ();
257
- $ context ->replaceResponse ($ this -> createGatewayTimeoutResponse ($ method , $ url , $ options ));
257
+ $ context ->replaceResponse (self :: createGatewayTimeoutResponse ($ method , $ url , $ options ));
258
258
259
259
return ;
260
260
}
@@ -304,7 +304,7 @@ function (ChunkInterface $chunk, AsyncContext $context) use (
304
304
'headers ' => array_diff_key ($ headers , self ::EXCLUDED_HEADERS ),
305
305
'initial_age ' => (int ) ($ headers ['age ' ][0 ] ?? 0 ),
306
306
'stored_at ' => time (),
307
- 'expires_at ' => $ this -> calculateExpiresAt ($ maxAge ),
307
+ 'expires_at ' => self :: calculateExpiresAt ($ maxAge ),
308
308
'chunks_count ' => $ chunkIndex ,
309
309
])
310
310
->expiresAt ($ expiresAt )
@@ -457,7 +457,7 @@ private static function buildVariantKey(array $normalizedHeaders, array $varyFie
457
457
*
458
458
* @return array<string, string|true> the parsed Cache-Control directives
459
459
*/
460
- private function parseCacheControlHeader (array $ header ): array
460
+ private static function parseCacheControlHeader (array $ header ): array
461
461
{
462
462
$ parsed = [];
463
463
foreach ($ header as $ line ) {
@@ -484,7 +484,7 @@ private function parseCacheControlHeader(array $header): array
484
484
*/
485
485
private function evaluateCacheFreshness (array $ data ): Freshness
486
486
{
487
- $ parseCacheControlHeader = $ this -> parseCacheControlHeader ($ data ['headers ' ]['cache-control ' ] ?? []);
487
+ $ parseCacheControlHeader = self :: parseCacheControlHeader ($ data ['headers ' ]['cache-control ' ] ?? []);
488
488
489
489
if (isset ($ parseCacheControlHeader ['no-cache ' ])) {
490
490
return Freshness::Stale;
@@ -535,7 +535,7 @@ private function evaluateCacheFreshness(array $data): Freshness
535
535
*/
536
536
private function determineMaxAge (array $ headers , array $ cacheControl ): ?int
537
537
{
538
- $ age = $ this -> getCurrentAge ($ headers );
538
+ $ age = self :: getCurrentAge ($ headers );
539
539
540
540
if ($ this ->sharedCache && isset ($ cacheControl ['s-maxage ' ])) {
541
541
$ sharedMaxAge = (int ) $ cacheControl ['s-maxage ' ];
@@ -589,7 +589,7 @@ private function determineMaxAge(array $headers, array $cacheControl): ?int
589
589
*
590
590
* @return int The age of the response in seconds. Defaults to 0 if not present.
591
591
*/
592
- private function getCurrentAge (array $ headers ): int
592
+ private static function getCurrentAge (array $ headers ): int
593
593
{
594
594
return (int ) ($ headers ['age ' ][0 ] ?? 0 );
595
595
}
@@ -601,7 +601,7 @@ private function getCurrentAge(array $headers): int
601
601
*
602
602
* @return int|null the expiration time of the response as a Unix timestamp, or null if the maximum age is null
603
603
*/
604
- private function calculateExpiresAt (?int $ maxAge ): ?int
604
+ private static function calculateExpiresAt (?int $ maxAge ): ?int
605
605
{
606
606
if (null === $ maxAge ) {
607
607
return null ;
@@ -700,7 +700,7 @@ private function createResponseFromCache(string $key, array $cachedData, string
700
700
);
701
701
}
702
702
703
- private function createGatewayTimeoutResponse (string $ method , string $ url , array $ options ): MockResponse
703
+ private static function createGatewayTimeoutResponse (string $ method , string $ url , array $ options ): MockResponse
704
704
{
705
705
return MockResponse::fromRequest (
706
706
$ method ,
0 commit comments