From 44e8f75b85b539aced68c1750a06e1c83b3723ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Mon, 12 Jan 2026 12:19:01 +0100 Subject: [PATCH 1/4] Load PHP files in DI, remove XML config --- .../FOSHttpCacheExtension.php | 70 +++++++-------- src/Resources/config/attributes.xml | 12 --- .../config/cache_control_listener.xml | 30 ------- src/Resources/config/cache_manager.xml | 30 ------- .../config/cache_manager_commands.xml | 30 ------- src/Resources/config/cache_tagging.xml | 34 -------- .../config/cache_tagging_commands.xml | 13 --- src/Resources/config/cache_tagging_twig.xml | 13 --- src/Resources/config/cloudflare.xml | 19 ---- src/Resources/config/cloudfront.xml | 16 ---- src/Resources/config/fastly.xml | 19 ---- src/Resources/config/flash_message.xml | 14 --- .../config/invalidation_listener.xml | 17 ---- src/Resources/config/matcher.xml | 86 ------------------- src/Resources/config/nginx.xml | 18 ---- src/Resources/config/nginx_proxy.xml | 23 ----- src/Resources/config/noop.xml | 14 --- src/Resources/config/symfony.xml | 18 ---- src/Resources/config/user_context.xml | 47 ---------- src/Resources/config/varnish.xml | 18 ---- src/Resources/config/varnish_proxy.xml | 23 ----- 21 files changed, 35 insertions(+), 529 deletions(-) delete mode 100644 src/Resources/config/attributes.xml delete mode 100644 src/Resources/config/cache_control_listener.xml delete mode 100644 src/Resources/config/cache_manager.xml delete mode 100644 src/Resources/config/cache_manager_commands.xml delete mode 100644 src/Resources/config/cache_tagging.xml delete mode 100644 src/Resources/config/cache_tagging_commands.xml delete mode 100644 src/Resources/config/cache_tagging_twig.xml delete mode 100644 src/Resources/config/cloudflare.xml delete mode 100644 src/Resources/config/cloudfront.xml delete mode 100755 src/Resources/config/fastly.xml delete mode 100644 src/Resources/config/flash_message.xml delete mode 100644 src/Resources/config/invalidation_listener.xml delete mode 100644 src/Resources/config/matcher.xml delete mode 100644 src/Resources/config/nginx.xml delete mode 100644 src/Resources/config/nginx_proxy.xml delete mode 100644 src/Resources/config/noop.xml delete mode 100644 src/Resources/config/symfony.xml delete mode 100644 src/Resources/config/user_context.xml delete mode 100644 src/Resources/config/varnish.xml delete mode 100644 src/Resources/config/varnish_proxy.xml diff --git a/src/DependencyInjection/FOSHttpCacheExtension.php b/src/DependencyInjection/FOSHttpCacheExtension.php index 15e1aea3..37abc6b6 100644 --- a/src/DependencyInjection/FOSHttpCacheExtension.php +++ b/src/DependencyInjection/FOSHttpCacheExtension.php @@ -27,7 +27,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Twig\TwigFunction; @@ -44,15 +44,15 @@ public function load(array $configs, ContainerBuilder $container): void $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('matcher.xml'); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader->load('matcher.php'); if ($config['debug']['enabled'] || (!empty($config['cache_control']))) { $debugHeader = $config['debug']['enabled'] ? $config['debug']['header'] : false; $ttlHeader = $config['cache_control']['ttl_header'] ?? CacheControlListener::DEFAULT_TTL_HEADER_NAME; $container->setParameter('fos_http_cache.debug_header', $debugHeader); $container->setParameter('fos_http_cache.ttl_header', $ttlHeader); - $loader->load('cache_control_listener.xml'); + $loader->load('cache_control_listener.php'); } $this->loadCacheable($container, $config['cacheable']); @@ -99,9 +99,9 @@ public function load(array $configs, ContainerBuilder $container): void $generateUrlType = $config['cache_manager']['generate_url_type']; } $container->setParameter('fos_http_cache.cache_manager.generate_url_type', $generateUrlType); - $loader->load('cache_manager.xml'); + $loader->load('cache_manager.php'); if (class_exists(Application::class)) { - $loader->load('cache_manager_commands.xml'); + $loader->load('cache_manager_commands.php'); } } @@ -117,7 +117,7 @@ public function load(array $configs, ContainerBuilder $container): void } if ($config['invalidation']['enabled']) { - $loader->load('invalidation_listener.xml'); + $loader->load('invalidation_listener.php'); if (!empty($config['invalidation']['expression_language'])) { $container->setAlias( @@ -139,10 +139,10 @@ public function load(array $configs, ContainerBuilder $container): void unset($config['flash_message']['enabled']); $container->setParameter('fos_http_cache.event_listener.flash_message.options', $config['flash_message']); - $loader->load('flash_message.xml'); + $loader->load('flash_message.php'); } - $loader->load('attributes.xml'); + $loader->load('attributes.php'); } private function loadCacheable(ContainerBuilder $container, array $config): void @@ -279,7 +279,7 @@ private function parseResponseMatcher(ContainerBuilder $container, array $config return new Reference('fos_http_cache.response_matcher.cacheable'); } - private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadUserContext(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $configuredUserIdentifierHeaders = array_map('strtolower', $config['user_identifier_headers']); $completeUserIdentifierHeaders = $configuredUserIdentifierHeaders; @@ -287,7 +287,7 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa $completeUserIdentifierHeaders[] = 'cookie'; } - $loader->load('user_context.xml'); + $loader->load('user_context.php'); $container->getDefinition('fos_http_cache.user_context.request_matcher') ->replaceArgument(0, $config['match']['accept']) @@ -326,7 +326,7 @@ private function loadUserContext(ContainerBuilder $container, XmlFileLoader $loa } } - private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadProxyClient(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { if (isset($config['varnish'])) { $this->loadVarnish($container, $loader, $config['varnish']); @@ -347,7 +347,7 @@ private function loadProxyClient(ContainerBuilder $container, XmlFileLoader $loa $this->loadFastly($container, $loader, $config['fastly']); } if (isset($config['noop'])) { - $loader->load('noop.xml'); + $loader->load('noop.php'); } $container->setAlias( @@ -410,7 +410,7 @@ private function createHttpDispatcherDefinition(ContainerBuilder $container, arr $container->setDefinition($serviceName, $definition); } - private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadVarnish(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.varnish.http_dispatcher'); $options = [ @@ -426,7 +426,7 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader, } $container->setParameter('fos_http_cache.proxy_client.varnish.options', $options); - $loader->load('varnish.xml'); + $loader->load('varnish.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -441,13 +441,13 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader, ->replaceArgument(3, $streamFactory); } - private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadNginx(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.nginx.http_dispatcher'); $container->setParameter('fos_http_cache.proxy_client.nginx.options', [ 'purge_location' => $config['purge_location'], ]); - $loader->load('nginx.xml'); + $loader->load('nginx.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -462,7 +462,7 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a ->replaceArgument(3, $streamFactory); } - private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadSymfony(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $serviceName = 'fos_http_cache.proxy_client.symfony.http_dispatcher'; @@ -485,7 +485,7 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, } $container->setParameter('fos_http_cache.proxy_client.symfony.options', $options); - $loader->load('symfony.xml'); + $loader->load('symfony.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -500,7 +500,7 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, ->replaceArgument(3, $streamFactory); } - private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadCloudflare(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.cloudflare.http_dispatcher'); $options = [ @@ -510,7 +510,7 @@ private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $load $container->setParameter('fos_http_cache.proxy_client.cloudflare.options', $options); - $loader->load('cloudflare.xml'); + $loader->load('cloudflare.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -525,7 +525,7 @@ private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $load ->replaceArgument(3, $streamFactory); } - private function loadCloudfront(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadCloudfront(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { if (null !== $config['client']) { $container->setAlias( @@ -543,10 +543,10 @@ private function loadCloudfront(ContainerBuilder $container, XmlFileLoader $load 'distribution_id' => $config['distribution_id'], ]); - $loader->load('cloudfront.xml'); + $loader->load('cloudfront.php'); } - private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadFastly(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $this->createHttpDispatcherDefinition($container, $config['http'], 'fos_http_cache.proxy_client.fastly.http_dispatcher'); @@ -558,7 +558,7 @@ private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader, $container->setParameter('fos_http_cache.proxy_client.fastly.options', $options); - $loader->load('fastly.xml'); + $loader->load('fastly.php'); $requestFactory = isset($config['http']['request_factory']) ? new Reference($config['http']['request_factory']) @@ -578,7 +578,7 @@ private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader, * @param string $client Name of the client used with the cache manager, * "custom" when a custom client is used */ - private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $loader, array $config, string $client): void + private function loadCacheTagging(ContainerBuilder $container, PhpFileLoader $loader, array $config, string $client): void { if ('auto' === $config['enabled'] && !in_array($client, ['varnish', 'symfony', 'cloudflare', 'fastly'])) { return; @@ -591,12 +591,12 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo $container->setParameter('fos_http_cache.tag_handler.separator', $config['separator']); $container->setParameter('fos_http_cache.tag_handler.strict', $config['strict']); - $loader->load('cache_tagging.xml'); + $loader->load('cache_tagging.php'); if (class_exists(TwigFunction::class)) { - $loader->load('cache_tagging_twig.xml'); + $loader->load('cache_tagging_twig.php'); } if (class_exists(Application::class)) { - $loader->load('cache_tagging_commands.xml'); + $loader->load('cache_tagging_commands.php'); } if (!empty($config['expression_language'])) { @@ -618,7 +618,7 @@ private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $lo } } - private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadTest(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { $container->setParameter('fos_http_cache.test.cache_header', $config['cache_header']); @@ -627,7 +627,7 @@ private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, ar } } - private function loadProxyServer(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadProxyServer(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { if (isset($config['varnish'])) { $this->loadVarnishProxyServer($container, $loader, $config['varnish']); @@ -643,9 +643,9 @@ private function loadProxyServer(ContainerBuilder $container, XmlFileLoader $loa ); } - private function loadVarnishProxyServer(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadVarnishProxyServer(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { - $loader->load('varnish_proxy.xml'); + $loader->load('varnish_proxy.php'); foreach ($config as $key => $value) { $container->setParameter( 'fos_http_cache.test.proxy_server.varnish.'.$key, @@ -654,9 +654,9 @@ private function loadVarnishProxyServer(ContainerBuilder $container, XmlFileLoad } } - private function loadNginxProxyServer(ContainerBuilder $container, XmlFileLoader $loader, array $config): void + private function loadNginxProxyServer(ContainerBuilder $container, PhpFileLoader $loader, array $config): void { - $loader->load('nginx_proxy.xml'); + $loader->load('nginx_proxy.php'); foreach ($config as $key => $value) { $container->setParameter( 'fos_http_cache.test.proxy_server.nginx.'.$key, diff --git a/src/Resources/config/attributes.xml b/src/Resources/config/attributes.xml deleted file mode 100644 index 99c7f426..00000000 --- a/src/Resources/config/attributes.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/src/Resources/config/cache_control_listener.xml b/src/Resources/config/cache_control_listener.xml deleted file mode 100644 index 3249d0a3..00000000 --- a/src/Resources/config/cache_control_listener.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - %fos_http_cache.debug_header% - %fos_http_cache.ttl_header% - - - - - - - - - - - - diff --git a/src/Resources/config/cache_manager.xml b/src/Resources/config/cache_manager.xml deleted file mode 100644 index a09742db..00000000 --- a/src/Resources/config/cache_manager.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - %fos_http_cache.cache_manager.generate_url_type% - - - - - - - - - - diff --git a/src/Resources/config/cache_manager_commands.xml b/src/Resources/config/cache_manager_commands.xml deleted file mode 100644 index 297f45ab..00000000 --- a/src/Resources/config/cache_manager_commands.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/cache_tagging.xml b/src/Resources/config/cache_tagging.xml deleted file mode 100644 index b23abb88..00000000 --- a/src/Resources/config/cache_tagging.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %fos_http_cache.tag_handler.response_header% - %fos_http_cache.tag_handler.separator% - - - - - - %fos_http_cache.tag_handler.strict% - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/cache_tagging_commands.xml b/src/Resources/config/cache_tagging_commands.xml deleted file mode 100644 index 1b449e17..00000000 --- a/src/Resources/config/cache_tagging_commands.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/src/Resources/config/cache_tagging_twig.xml b/src/Resources/config/cache_tagging_twig.xml deleted file mode 100644 index 192c85a5..00000000 --- a/src/Resources/config/cache_tagging_twig.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/src/Resources/config/cloudflare.xml b/src/Resources/config/cloudflare.xml deleted file mode 100644 index 5e92d5a6..00000000 --- a/src/Resources/config/cloudflare.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.cloudflare.options% - - - - - - diff --git a/src/Resources/config/cloudfront.xml b/src/Resources/config/cloudfront.xml deleted file mode 100644 index 2f827756..00000000 --- a/src/Resources/config/cloudfront.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.cloudfront.options% - - - - diff --git a/src/Resources/config/fastly.xml b/src/Resources/config/fastly.xml deleted file mode 100755 index 41277e2f..00000000 --- a/src/Resources/config/fastly.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.fastly.options% - - - - - - diff --git a/src/Resources/config/flash_message.xml b/src/Resources/config/flash_message.xml deleted file mode 100644 index 0f4dc85a..00000000 --- a/src/Resources/config/flash_message.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - %fos_http_cache.event_listener.flash_message.options% - - - - diff --git a/src/Resources/config/invalidation_listener.xml b/src/Resources/config/invalidation_listener.xml deleted file mode 100644 index 7576bdd8..00000000 --- a/src/Resources/config/invalidation_listener.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Resources/config/matcher.xml b/src/Resources/config/matcher.xml deleted file mode 100644 index 7451a423..00000000 --- a/src/Resources/config/matcher.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %fos_http_cache.cacheable.response.additional_status% - - - - - diff --git a/src/Resources/config/nginx.xml b/src/Resources/config/nginx.xml deleted file mode 100644 index f9421820..00000000 --- a/src/Resources/config/nginx.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.nginx.options% - - - - - - diff --git a/src/Resources/config/nginx_proxy.xml b/src/Resources/config/nginx_proxy.xml deleted file mode 100644 index dcbb4de8..00000000 --- a/src/Resources/config/nginx_proxy.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - %fos_http_cache.test.proxy_server.nginx.config_file% - - %fos_http_cache.test.proxy_server.nginx.binary% - - - %fos_http_cache.test.proxy_server.nginx.port% - - - %fos_http_cache.test.proxy_server.nginx.ip% - - - - - diff --git a/src/Resources/config/noop.xml b/src/Resources/config/noop.xml deleted file mode 100644 index 379c865b..00000000 --- a/src/Resources/config/noop.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/src/Resources/config/symfony.xml b/src/Resources/config/symfony.xml deleted file mode 100644 index fcf2e334..00000000 --- a/src/Resources/config/symfony.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.symfony.options% - - - - - - diff --git a/src/Resources/config/user_context.xml b/src/Resources/config/user_context.xml deleted file mode 100644 index 11954d72..00000000 --- a/src/Resources/config/user_context.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - %fos_http_cache.event_listener.user_context.options% - true - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Resources/config/varnish.xml b/src/Resources/config/varnish.xml deleted file mode 100644 index 57216740..00000000 --- a/src/Resources/config/varnish.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - %fos_http_cache.proxy_client.varnish.options% - - - - - - diff --git a/src/Resources/config/varnish_proxy.xml b/src/Resources/config/varnish_proxy.xml deleted file mode 100644 index 508fadaa..00000000 --- a/src/Resources/config/varnish_proxy.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - %fos_http_cache.test.proxy_server.varnish.config_file% - - %fos_http_cache.test.proxy_server.varnish.binary% - - - %fos_http_cache.test.proxy_server.varnish.port% - - - %fos_http_cache.test.proxy_server.varnish.ip% - - - - - From 2f48e7b687a63c7d0e69cf778e3fd8ab6f418305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Mon, 12 Jan 2026 13:45:41 +0100 Subject: [PATCH 2/4] Disable Composer audit --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 7bbfeba6..3d0c3bea 100644 --- a/composer.json +++ b/composer.json @@ -90,6 +90,9 @@ "allow-plugins": { "php-http/discovery": true, "phpstan/extension-installer": true + }, + "audit": { + "block-insecure": false } } } From ff65f401580b11b96b64c5dcd2628dfe0ceef0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Mon, 12 Jan 2026 13:47:30 +0100 Subject: [PATCH 3/4] Only test XML configuration on Symfony < 8.0 --- .../DependencyInjection/ConfigurationTest.php | 101 ++++++++++++++---- 1 file changed, 81 insertions(+), 20 deletions(-) diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 3a867380..7ed2284d 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -20,6 +20,7 @@ use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; +use Symfony\Component\HttpKernel\Kernel; class ConfigurationTest extends AbstractExtensionConfigurationTestCase { @@ -41,10 +42,13 @@ public function testEmptyConfiguration(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/empty.yml', - 'config/empty.xml', 'config/empty.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/empty.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -199,10 +203,13 @@ public function testSupportsAllConfigFormats(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/full.yml', - 'config/full.xml', 'config/full.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/full.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -224,10 +231,13 @@ public function testCustomProxyClient(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/custom-client.yml', - 'config/custom-client.xml', 'config/custom-client.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/custom-client.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -258,10 +268,13 @@ public function testSupportsNginx(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/nginx.yml', - 'config/nginx.xml', 'config/nginx.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/nginx.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -296,10 +309,13 @@ public function testSupportsSymfony(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/symfony.yml', - 'config/symfony.xml', 'config/symfony.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/symfony.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -325,10 +341,13 @@ public function testSupportsCloudflare(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cloudflare.yml', - 'config/cloudflare.xml', 'config/cloudflare.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cloudflare.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -357,10 +376,13 @@ public function testSupportsCloudfront(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cloudfront.yml', - 'config/cloudfront.xml', 'config/cloudfront.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cloudfront.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -410,10 +432,13 @@ public function testSupportsFastly(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/fastly.yml', - 'config/fastly.xml', 'config/fastly.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/fastly.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -468,10 +493,13 @@ public function testSupportsNoop(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/noop.yml', - 'config/noop.xml', 'config/noop.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/noop.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -539,10 +567,13 @@ public function testSplitOptions(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/split.yml', - 'config/split.xml', 'config/split.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/split.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -558,10 +589,13 @@ public function testSupportsCacheableResponseExpression(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cacheable_response_expression.yml', - 'config/cacheable_response_expression.xml', 'config/cacheable_response_expression.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cacheable_response_expression.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -573,10 +607,13 @@ public function testCacheManagerNoClient(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/cachemanager_noclient.yml', - 'config/cachemanager_noclient.xml', 'config/cachemanager_noclient.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/cachemanager_noclient.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -593,10 +630,13 @@ public function testTagsNoCacheManager(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/tags_nocachemanager.yml', - 'config/tags_nocachemanager.xml', 'config/tags_nocachemanager.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/tags_nocachemanager.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -616,10 +656,13 @@ public function testTagsStrict(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/tags_strict.yml', - 'config/tags_strict.xml', 'config/tags_strict.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/tags_strict.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -659,10 +702,13 @@ public function testWeakETags(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/etag_weak.yml', - 'config/etag_weak.xml', 'config/etag_weak.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/etag_weak.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -702,10 +748,13 @@ public function testStrongETags(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/etag_true.yml', - 'config/etag_true.xml', 'config/etag_true.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/etag_true.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -717,10 +766,13 @@ public function testInvalidationNoCacheManager(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/invalidation_nocachemanager.yml', - 'config/invalidation_nocachemanager.xml', 'config/invalidation_nocachemanager.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/invalidation_nocachemanager.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -785,10 +837,13 @@ public function testInvalidDate(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/invalid_date.yml', - 'config/invalid_date.xml', 'config/invalid_date.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/invalid_date.xml'; + } + foreach ($formats as $format) { try { $this->assertProcessedConfigurationEquals([], [$format]); @@ -825,10 +880,13 @@ public function testSupportsServersFromJsonEnv(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/servers_from_jsonenv.yml', - 'config/servers_from_jsonenv.xml', 'config/servers_from_jsonenv.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/servers_from_jsonenv.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } @@ -860,10 +918,13 @@ public function testConfigureExpressionLanguageService(): void return __DIR__.'/../../Resources/Fixtures/'.$path; }, [ 'config/servers_from_jsonenv.yml', - 'config/servers_from_jsonenv.xml', 'config/servers_from_jsonenv.php', ]); + if (version_compare(Kernel::VERSION, '8.0.0', '<')) { + $formats[] = __DIR__.'/../../Resources/Fixtures/config/servers_from_jsonenv.xml'; + } + foreach ($formats as $format) { $this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]); } From dfafa153a73837adb3b63b1adfc7b19d7f404110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Mon, 12 Jan 2026 13:58:40 +0100 Subject: [PATCH 4/4] Use Application::addCommand if available --- tests/Unit/Command/BaseInvalidateCommandTest.php | 3 ++- tests/Unit/Command/ClearCommandTest.php | 9 ++++++--- tests/Unit/Command/InvalidatePathCommandTest.php | 6 ++++-- tests/Unit/Command/InvalidateRegexCommandTest.php | 6 ++++-- tests/Unit/Command/InvalidateTagCommandTest.php | 6 ++++-- tests/Unit/Command/RefreshPathCommandTest.php | 6 ++++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/Unit/Command/BaseInvalidateCommandTest.php b/tests/Unit/Command/BaseInvalidateCommandTest.php index 273c722c..a2551f80 100644 --- a/tests/Unit/Command/BaseInvalidateCommandTest.php +++ b/tests/Unit/Command/BaseInvalidateCommandTest.php @@ -35,8 +35,9 @@ public function testContainerAccess(): void ; $application = new Application(); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; $command = new InvalidatePathCommand($invalidator); - $application->add($command); + $application->$addMethod($command); $command = $application->find('fos:httpcache:invalidate:path'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/ClearCommandTest.php b/tests/Unit/Command/ClearCommandTest.php index 7da0e2bf..58223dbf 100644 --- a/tests/Unit/Command/ClearCommandTest.php +++ b/tests/Unit/Command/ClearCommandTest.php @@ -32,7 +32,8 @@ public function testExecuteClear(): void ; $application = new Application(); - $application->add(new ClearCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new ClearCommand($invalidator)); $command = $application->find('fos:httpcache:clear'); $commandTester = new CommandTester($command); @@ -54,7 +55,8 @@ public function testExecuteInvalidate(): void ; $application = new Application(); - $application->add(new ClearCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new ClearCommand($invalidator)); $command = $application->find('fos:httpcache:clear'); $commandTester = new CommandTester($command); @@ -75,7 +77,8 @@ public function testExecuteNotSupported(): void ; $application = new Application(); - $application->add(new ClearCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new ClearCommand($invalidator)); $command = $application->find('fos:httpcache:clear'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/InvalidatePathCommandTest.php b/tests/Unit/Command/InvalidatePathCommandTest.php index 99b37d41..980da134 100644 --- a/tests/Unit/Command/InvalidatePathCommandTest.php +++ b/tests/Unit/Command/InvalidatePathCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new InvalidatePathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidatePathCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:path'); $commandTester = new CommandTester($command); @@ -45,7 +46,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new InvalidatePathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidatePathCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:path'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/InvalidateRegexCommandTest.php b/tests/Unit/Command/InvalidateRegexCommandTest.php index 6a78b454..3f83779c 100644 --- a/tests/Unit/Command/InvalidateRegexCommandTest.php +++ b/tests/Unit/Command/InvalidateRegexCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteNoParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new InvalidateRegexCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateRegexCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:regex'); $commandTester = new CommandTester($command); @@ -44,7 +45,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new InvalidateRegexCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateRegexCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:regex'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/InvalidateTagCommandTest.php b/tests/Unit/Command/InvalidateTagCommandTest.php index 97478147..bf6c2a8f 100644 --- a/tests/Unit/Command/InvalidateTagCommandTest.php +++ b/tests/Unit/Command/InvalidateTagCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new InvalidateTagCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateTagCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:tag'); $commandTester = new CommandTester($command); @@ -44,7 +45,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new InvalidateTagCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new InvalidateTagCommand($invalidator)); $command = $application->find('fos:httpcache:invalidate:tag'); $commandTester = new CommandTester($command); diff --git a/tests/Unit/Command/RefreshPathCommandTest.php b/tests/Unit/Command/RefreshPathCommandTest.php index 05595284..3302053f 100644 --- a/tests/Unit/Command/RefreshPathCommandTest.php +++ b/tests/Unit/Command/RefreshPathCommandTest.php @@ -29,7 +29,8 @@ public function testExecuteMissingParameters(): void $invalidator = \Mockery::mock(CacheManager::class); $application = new Application(); - $application->add(new RefreshPathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new RefreshPathCommand($invalidator)); $command = $application->find('fos:httpcache:refresh:path'); $commandTester = new CommandTester($command); @@ -45,7 +46,8 @@ public function testExecuteParameter(): void ; $application = new Application(); - $application->add(new RefreshPathCommand($invalidator)); + $addMethod = method_exists($application, 'addCommand') ? 'addCommand' : 'add'; + $application->$addMethod(new RefreshPathCommand($invalidator)); $command = $application->find('fos:httpcache:refresh:path'); $commandTester = new CommandTester($command);