Skip to content

Commit bfb63a3

Browse files
committed
Adapt CacheInvalidation classes according to code review
1 parent 9a9c27b commit bfb63a3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/SymfonyCache/CacheInvalidation.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111

1212
namespace FOS\HttpCache\SymfonyCache;
1313

14+
use Symfony\Component\HttpKernel\Kernel;
1415
use Symfony\Component\HttpKernel\HttpKernelInterface;
1516

1617
use function class_alias;
1718
use function class_exists;
1819

19-
if (! interface_exists(CacheInvalidation::class) &&
20-
class_exists('Symfony\Component\HttpKernel\Kernel') &&
21-
\Symfony\Component\HttpKernel\Kernel::MAJOR_VERSION >= 6) {
20+
if (interface_exists(CacheInvalidation::class)) {
21+
return;
22+
}
23+
24+
/*
25+
* Symfony 6 introduced a BC break in the signature of the protected method HttpKernelInterface::fetch.
26+
* Load the correct interface to match the signature.
27+
*/
28+
if (class_exists(Kernel::class) && Kernel::MAJOR_VERSION >= 6) {
2229
// Load class for Symfony >=6.0
2330
class_alias(
2431
Compatibility\CacheInvalidationS6::class,

src/SymfonyCache/Compatibility/CacheInvalidationLegacy.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
/**
2020
* Interface for a HttpCache that supports active cache invalidation.
21+
*
22+
* Method signature of `fetch` and `getStore` compatible with Symfony 5 and older.
2123
*/
2224
interface CacheInvalidationLegacy extends HttpKernelInterface
2325
{

src/SymfonyCache/Compatibility/CacheInvalidationS6.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
/**
2020
* Interface for a HttpCache that supports active cache invalidation.
21+
*
22+
* Method signature of `fetch` and `getStore` compatible with Symfony 6 or newer.
2123
*/
2224
interface CacheInvalidationS6 extends HttpKernelInterface
2325
{

0 commit comments

Comments
 (0)