From 5ad76b39b6aa5d1776ce29be25f56cdecec2b5a7 Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Thu, 29 Oct 2026 07:50:11 +0100 Subject: [PATCH 1/9] Refactoring to have php config file --- .../LexikCronFileGeneratorExtension.php | 8 +- Resources/config/console.php | 14 +++ Resources/config/console.xml | 14 --- Resources/config/dump_file.php | 24 +++++ Resources/config/dump_file.xml | 25 ----- .../LexikCronFileGeneratorExtensionTest.php | 98 ++++++++++++++----- composer.json | 12 +-- 7 files changed, 121 insertions(+), 74 deletions(-) create mode 100644 Resources/config/console.php delete mode 100644 Resources/config/console.xml create mode 100644 Resources/config/dump_file.php delete mode 100644 Resources/config/dump_file.xml diff --git a/DependencyInjection/LexikCronFileGeneratorExtension.php b/DependencyInjection/LexikCronFileGeneratorExtension.php index 6bc877c..96039c4 100644 --- a/DependencyInjection/LexikCronFileGeneratorExtension.php +++ b/DependencyInjection/LexikCronFileGeneratorExtension.php @@ -6,7 +6,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; class LexikCronFileGeneratorExtension extends Extension { @@ -14,10 +14,10 @@ public function load(array $configs, ContainerBuilder $container): void { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('dump_file.xml'); - $loader->load('console.xml'); + $loader->load('dump_file.php'); + $loader->load('console.php'); $container->setParameter('lexik_cron_file_generator.cron.configuration_arguments', $config); $container->setAlias(DumpFile::class, 'lexik_cron_file_generator.cron.dump_file'); diff --git a/Resources/config/console.php b/Resources/config/console.php new file mode 100644 index 0000000..97401f1 --- /dev/null +++ b/Resources/config/console.php @@ -0,0 +1,14 @@ +services() + ->set('lexik_bundle_cron_file_generator.command.generate_cron_command', GenerateCronCommand::class) + ->public() + ->args([service('lexik_bundle_cron_file_generator.cron.dump_file_factory')]) + ->tag('console.command', ['command' => 'lexik:cron:generate-file']); +}; diff --git a/Resources/config/console.xml b/Resources/config/console.xml deleted file mode 100644 index 9443143..0000000 --- a/Resources/config/console.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Resources/config/dump_file.php b/Resources/config/dump_file.php new file mode 100644 index 0000000..53baba5 --- /dev/null +++ b/Resources/config/dump_file.php @@ -0,0 +1,24 @@ +services() + ->set('lexik_bundle_cron_file_generator.cron.dump_file_factory', DumpFileFactory::class) + ->public() + ->args([service('lexik_cron_file_generator.cron.dump_file')]) + + ->set('lexik_cron_file_generator.cron.dump_file', DumpFile::class) + ->public() + ->args([service('twig'), service('lexik_cron_file_generator.cron.configuration')]) + + ->set('lexik_cron_file_generator.cron.configuration', Configuration::class) + ->private() + ->args([param('lexik_cron_file_generator.cron.configuration_arguments')]); +}; diff --git a/Resources/config/dump_file.xml b/Resources/config/dump_file.xml deleted file mode 100644 index ce5373d..0000000 --- a/Resources/config/dump_file.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - %lexik_cron_file_generator.cron.configuration_arguments% - - - - \ No newline at end of file diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php index b020a6d..1d397d4 100644 --- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php +++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php @@ -2,7 +2,10 @@ namespace Lexik\Bundle\CronFileGeneratorBundle\Tests\DependencyInjection; +use Lexik\Bundle\CronFileGeneratorBundle\Command\GenerateCronCommand; +use Lexik\Bundle\CronFileGeneratorBundle\Cron\Configuration; use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFile; +use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFileFactory; use Lexik\Bundle\CronFileGeneratorBundle\DependencyInjection\LexikCronFileGeneratorExtension; use Lexik\Bundle\CronFileGeneratorBundle\LexikCronFileGeneratorBundle; use Lexik\Bundle\CronFileGeneratorBundle\Tests\Stubs\Autowired; @@ -14,6 +17,7 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Kernel; class LexikCronFileGeneratorExtensionTest extends TestCase @@ -30,31 +34,7 @@ public function testLoadConfiguration() 'strict_variables' => true, 'exception_controller' => null, // to be removed in 5.0 ], - 'lexik_cron_file_generator' => [ - 'env_available' => [ - 'staging', 'prod', - ], - 'user' => [ - 'staging' => 'project_staging', - 'prod' => 'project_prod', - ], - 'php_version' => 'php7.3', - 'absolute_path' => [ - 'staging' => 'path/to/staging', - 'prod' => 'path/to/prod', - ], - 'output_path' => 'path/to/cron_file', - 'crons' => [ - [ - 'name' => 'test', - 'command' => 'app:test', - 'env' => [ - 'staging' => '* * * * *', - 'prod' => '* 5 * * *', - ], - ], - ], - ], + 'lexik_cron_file_generator' => $this->getBundleConfig(), ]); $container @@ -68,6 +48,74 @@ public function testLoadConfiguration() $this->assertInstanceOf(DumpFile::class, $container->get('autowired')->getDumpFile()); } + public function testServiceDefinitions() + { + $container = new ContainerBuilder(); + (new LexikCronFileGeneratorExtension())->load([$this->getBundleConfig()], $container); + + $dumpFileFactory = $container->getDefinition('lexik_bundle_cron_file_generator.cron.dump_file_factory'); + $this->assertSame(DumpFileFactory::class, $dumpFileFactory->getClass()); + $this->assertTrue($dumpFileFactory->isPublic()); + $this->assertReferences(['lexik_cron_file_generator.cron.dump_file'], $dumpFileFactory->getArguments()); + + $dumpFile = $container->getDefinition('lexik_cron_file_generator.cron.dump_file'); + $this->assertSame(DumpFile::class, $dumpFile->getClass()); + $this->assertTrue($dumpFile->isPublic()); + $this->assertReferences(['twig', 'lexik_cron_file_generator.cron.configuration'], $dumpFile->getArguments()); + + $configuration = $container->getDefinition('lexik_cron_file_generator.cron.configuration'); + $this->assertSame(Configuration::class, $configuration->getClass()); + $this->assertTrue($configuration->isPrivate()); + $this->assertSame(['%lexik_cron_file_generator.cron.configuration_arguments%'], $configuration->getArguments()); + + $command = $container->getDefinition('lexik_bundle_cron_file_generator.command.generate_cron_command'); + $this->assertSame(GenerateCronCommand::class, $command->getClass()); + $this->assertTrue($command->isPublic()); + $this->assertReferences(['lexik_bundle_cron_file_generator.cron.dump_file_factory'], $command->getArguments()); + $this->assertSame([['command' => 'lexik:cron:generate-file']], $command->getTag('console.command')); + + $this->assertSame('lexik_cron_file_generator.cron.dump_file', (string) $container->getAlias(DumpFile::class)); + } + + private function assertReferences(array $expectedIds, array $arguments): void + { + $this->assertCount(\count($expectedIds), $arguments); + + foreach ($expectedIds as $index => $expectedId) { + $this->assertInstanceOf(Reference::class, $arguments[$index]); + $this->assertSame($expectedId, (string) $arguments[$index]); + } + } + + private function getBundleConfig(): array + { + return [ + 'env_available' => [ + 'staging', 'prod', + ], + 'user' => [ + 'staging' => 'project_staging', + 'prod' => 'project_prod', + ], + 'php_version' => 'php7.3', + 'absolute_path' => [ + 'staging' => 'path/to/staging', + 'prod' => 'path/to/prod', + ], + 'output_path' => 'path/to/cron_file', + 'crons' => [ + [ + 'name' => 'test', + 'command' => 'app:test', + 'env' => [ + 'staging' => '* * * * *', + 'prod' => '* 5 * * *', + ], + ], + ], + ]; + } + private function createContainer(array $configs = []): ContainerBuilder { $container = new ContainerBuilder(new ParameterBag([ diff --git a/composer.json b/composer.json index 449fe06..b6b698d 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,16 @@ } ], "require": { - "php": ">=7.2", - "symfony/console": "^4.4|^5.4|^6.0|^7.0", - "symfony/framework-bundle": "^4.4|^5.4|^6.0|^7.0", - "symfony/twig-bundle": "^4.4|^5.4|^6.0|^7.0", + "php": ">=7.2.5", + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/framework-bundle": "^5.4|^6.0|^7.0", + "symfony/twig-bundle": "^5.4|^6.0|^7.0", "twig/twig": "^v2.14.0|^3.0" }, "require-dev": { "symfony/phpunit-bridge": "^7.0.1", - "symfony/yaml": "^4.4|^5.4|^6.0|^7.0", - "symfony/var-dumper": "^4.4|^5.4|^6.0|^7.0" + "symfony/yaml": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "autoload": { "psr-4": { "Lexik\\Bundle\\CronFileGeneratorBundle\\": "" }, From 5b7a5b12628fc1704a0cde856a664bbed5ea0fde Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Thu, 29 Oct 2026 07:50:49 +0100 Subject: [PATCH 2/9] fix: Fixing tests for 7.4 symfony version --- .../LexikCronFileGeneratorExtensionTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php index 1d397d4..4da8b67 100644 --- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php +++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php @@ -123,7 +123,10 @@ private function createContainer(array $configs = []): ContainerBuilder 'kernel.root_dir' => __DIR__, 'kernel.project_dir' => __DIR__, 'kernel.build_dir' => __DIR__, + 'kernel.share_dir' => __DIR__, 'kernel.runtime_environment' => 'test', + 'kernel.runtime_mode.web' => false, + 'kernel.runtime_mode.cli' => true, 'kernel.charset' => 'UTF-8', 'kernel.environment' => 'test', 'kernel.debug' => false, @@ -134,6 +137,10 @@ private function createContainer(array $configs = []): ContainerBuilder 'LexikCronFileGeneratorBundle' => LexikCronFileGeneratorBundle::class, ], 'env(base64:default::SYMFONY_DECRYPTION_SECRET)' => 'dummy', + 'env(bool:default::SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER)' => false, + 'env(default::SYMFONY_TRUSTED_HOSTS)' => [], + 'env(default::SYMFONY_TRUSTED_HEADERS)' => [], + 'env(default::SYMFONY_TRUSTED_PROXIES)' => null, ])); $container->set( From 7491ae4e497ae05e97ab5bd6b5cccb3b3c75304d Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Thu, 29 Oct 2026 08:03:33 +0100 Subject: [PATCH 3/9] chore: Fixing CI version to maintain version only --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f362038..64ffc45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,13 +10,13 @@ jobs: continue-on-error: ${{ matrix.can-fail }} name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}" strategy: + fail-fast: false matrix: include: - - { os: ubuntu-20.04, php: 7.4, symfony: "5.4.*", composer-flags: "--prefer-stable --prefer-lowest", can-fail: false } + - { os: ubuntu-22.04, php: 7.4, symfony: "5.4.*", composer-flags: "--prefer-stable --prefer-lowest", can-fail: false } - { os: ubuntu-latest, php: 8.3, symfony: "6.4.*", composer-flags: "--prefer-stable", can-fail: false } - - { os: ubuntu-latest, php: 8.2, symfony: "6.3.*", composer-flags: "--prefer-stable", can-fail: false } - { os: ubuntu-latest, php: 8.2, symfony: "6.4.*", composer-flags: "--prefer-stable", can-fail: false } - - { os: ubuntu-latest, php: 8.3, symfony: "7.0.*", composer-flags: "--prefer-stable", can-fail: false } + - { os: ubuntu-latest, php: 8.3, symfony: "7.4.*", composer-flags: "--prefer-stable", can-fail: false } steps: - name: "Checkout" From bb8392607e3b849932873244dae62c7e25d26977 Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Mon, 2 Nov 2026 11:02:42 +0100 Subject: [PATCH 4/9] chore: Bump minimum requirements to PHP 8.1 and Symfony 6.4 --- composer.json | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index b6b698d..3f6034a 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,22 @@ } ], "require": { - "php": ">=7.2.5", - "symfony/console": "^5.4|^6.0|^7.0", - "symfony/framework-bundle": "^5.4|^6.0|^7.0", - "symfony/twig-bundle": "^5.4|^6.0|^7.0", - "twig/twig": "^v2.14.0|^3.0" + "php": ">=8.1", + "symfony/console": "^6.4|^7.4|^8.0", + "symfony/framework-bundle": "^6.4|^7.4|^8.0", + "symfony/twig-bundle": "^6.4|^7.4|^8.0", + "twig/twig": "^3.27" }, "require-dev": { - "symfony/phpunit-bridge": "^7.0.1", - "symfony/yaml": "^5.4|^6.0|^7.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0" + "symfony/phpunit-bridge": "^7.4|^8.0", + "symfony/yaml": "^6.4.45|^7.4.18|^8.1.6", + "symfony/var-dumper": "^6.4|^7.4|^8.0" + }, + "conflict": { + "symfony/cache": "<6.4.40|>=7.0,<7.4.12|>=8.0,<8.0.12", + "symfony/http-foundation": "<6.4.46|>=7.0,<7.4.19|>=8.0,<8.1.7", + "symfony/http-kernel": ">=7.4,<7.4.12|>=8.0,<8.0.12", + "symfony/routing": "<6.4.41|>=7.0,<7.4.13|>=8.0,<8.0.13" }, "autoload": { "psr-4": { "Lexik\\Bundle\\CronFileGeneratorBundle\\": "" }, From 9a82b3c020606d1febd37a8c365d16e6ab9b9be5 Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Mon, 2 Nov 2026 11:02:42 +0100 Subject: [PATCH 5/9] chore: Update CI matrix and harden workflow --- .github/workflows/ci.yml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64ffc45..f52c735 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,19 +4,20 @@ on: pull_request: push: +permissions: + contents: read + jobs: test: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.can-fail }} name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}" strategy: fail-fast: false matrix: include: - - { os: ubuntu-22.04, php: 7.4, symfony: "5.4.*", composer-flags: "--prefer-stable --prefer-lowest", can-fail: false } - - { os: ubuntu-latest, php: 8.3, symfony: "6.4.*", composer-flags: "--prefer-stable", can-fail: false } - - { os: ubuntu-latest, php: 8.2, symfony: "6.4.*", composer-flags: "--prefer-stable", can-fail: false } - - { os: ubuntu-latest, php: 8.3, symfony: "7.4.*", composer-flags: "--prefer-stable", can-fail: false } + - { os: ubuntu-latest, php: 8.1, symfony: "6.4.*", composer-flags: "--prefer-stable --prefer-lowest" } + - { os: ubuntu-latest, php: 8.2, symfony: "7.4.*", composer-flags: "--prefer-stable" } + - { os: ubuntu-latest, php: 8.4, symfony: "8.1.*", composer-flags: "--prefer-stable" } steps: - name: "Checkout" @@ -25,11 +26,11 @@ jobs: fetch-depth: 2 - name: "Cache Composer packages" - uses: "actions/cache@v3" + uses: "actions/cache@v4" with: path: "~/.composer/cache" key: "php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('composer.json') }}-flags-${{ matrix.composer-flags }}" - restore-keys: "php-" + restore-keys: "php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-" - name: "Install PHP" uses: "shivammathur/setup-php@v2" @@ -37,10 +38,19 @@ jobs: php-version: "${{ matrix.php }}" tools: "composer:v2,flex" + # Composer >= 2.9 skips vulnerable versions when resolving, which would hide + # vulnerable lower bounds from the audit below + - name: "Allow vulnerable versions to be resolved" + if: contains(matrix.composer-flags, '--prefer-lowest') + run: composer config --global audit.block-insecure false + - name: Install dependencies run: composer update ${{ matrix.composer-flags }} --prefer-dist env: SYMFONY_REQUIRE: "${{ matrix.symfony }}" + - name: "Audit dependencies" + run: composer audit + - name: Run PHPUnit Tests run: composer test From 4b3487c9086bf687577b2f8547f521b159dd4ecb Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Mon, 2 Nov 2026 11:02:42 +0100 Subject: [PATCH 6/9] refactor: Use AsCommand attribute on generate cron command --- Command/GenerateCronCommand.php | 14 ++++++-------- Resources/config/console.php | 2 +- .../LexikCronFileGeneratorExtensionTest.php | 2 +- .../Command/GenerateCronFileCommandTest.php | 9 +++++++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Command/GenerateCronCommand.php b/Command/GenerateCronCommand.php index 916063a..6894606 100644 --- a/Command/GenerateCronCommand.php +++ b/Command/GenerateCronCommand.php @@ -5,6 +5,7 @@ use Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFileFactory; use Lexik\Bundle\CronFileGeneratorBundle\Exception\CronEmptyException; use Lexik\Bundle\CronFileGeneratorBundle\Exception\WrongConsoleBinPathException; +use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -12,21 +13,18 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +#[AsCommand(name: 'lexik:cron:generate-file', description: 'Generate a cron file')] class GenerateCronCommand extends Command { - private DumpFileFactory $dumpFileFactory; - - public function __construct(DumpFileFactory $dumpFileFactory, string $name = 'lexik:cron:generate-file') - { - parent::__construct($name); - - $this->dumpFileFactory = $dumpFileFactory; + public function __construct( + private readonly DumpFileFactory $dumpFileFactory, + ) { + parent::__construct(); } protected function configure(): void { $this - ->setDescription('Generate a cron file') ->setHelp(<<<'EOPHP' The %command.name% generates cron file diff --git a/Resources/config/console.php b/Resources/config/console.php index 97401f1..e37ad94 100644 --- a/Resources/config/console.php +++ b/Resources/config/console.php @@ -10,5 +10,5 @@ ->set('lexik_bundle_cron_file_generator.command.generate_cron_command', GenerateCronCommand::class) ->public() ->args([service('lexik_bundle_cron_file_generator.cron.dump_file_factory')]) - ->tag('console.command', ['command' => 'lexik:cron:generate-file']); + ->tag('console.command'); }; diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php index 4da8b67..4ff6b63 100644 --- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php +++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php @@ -72,7 +72,7 @@ public function testServiceDefinitions() $this->assertSame(GenerateCronCommand::class, $command->getClass()); $this->assertTrue($command->isPublic()); $this->assertReferences(['lexik_bundle_cron_file_generator.cron.dump_file_factory'], $command->getArguments()); - $this->assertSame([['command' => 'lexik:cron:generate-file']], $command->getTag('console.command')); + $this->assertSame([[]], $command->getTag('console.command')); $this->assertSame('lexik_cron_file_generator.cron.dump_file', (string) $container->getAlias(DumpFile::class)); } diff --git a/Tests/Functional/Command/GenerateCronFileCommandTest.php b/Tests/Functional/Command/GenerateCronFileCommandTest.php index e39d84f..f3380bc 100644 --- a/Tests/Functional/Command/GenerateCronFileCommandTest.php +++ b/Tests/Functional/Command/GenerateCronFileCommandTest.php @@ -3,10 +3,19 @@ namespace Lexik\Bundle\CronFileGeneratorBundle\Tests\Functional\Command; use Lexik\Bundle\CronFileGeneratorBundle\Tests\Functional\TestCase; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Tester\CommandTester; class GenerateCronFileCommandTest extends TestCase { + public function testCommandIsRegisteredWithItsName() + { + $command = (new Application($this->bootKernel()))->find('lexik:cron:generate-file'); + + $this->assertSame('lexik:cron:generate-file', $command->getName()); + $this->assertSame('Generate a cron file', $command->getDescription()); + } + public function testGenerateFullConfiguration() { $kernel = $this->bootKernel(); From 161ff9e562b994c3d84a249079f4263ca21cc94a Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Mon, 2 Nov 2026 11:02:42 +0100 Subject: [PATCH 7/9] refactor: Remove dead compatibility code --- DependencyInjection/Configuration.php | 2 +- .../LexikCronFileGeneratorExtensionTest.php | 14 ++++++-- .../DependencyInjection/BundleExtension.php | 19 ++--------- .../Functional/ForwardCompatTestCaseTrait.php | 34 ------------------- Tests/Functional/TestCase.php | 2 -- Tests/Functional/app/config/base_config.yml | 1 - .../app/config/empty_cron_config.yml | 1 - 7 files changed, 15 insertions(+), 58 deletions(-) delete mode 100644 Tests/Functional/ForwardCompatTestCaseTrait.php diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3d99403..dba11ad 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -10,7 +10,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('lexik_cron_file_generator'); - $rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('lexik_cron_file_generator'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php index 4ff6b63..86c208d 100644 --- a/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php +++ b/Tests/DependencyInjection/LexikCronFileGeneratorExtensionTest.php @@ -16,6 +16,7 @@ use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Kernel\ServicesBundle; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Kernel; @@ -32,7 +33,6 @@ public function testLoadConfiguration() ], 'twig' => [ 'strict_variables' => true, - 'exception_controller' => null, // to be removed in 5.0 ], 'lexik_cron_file_generator' => $this->getBundleConfig(), ]); @@ -151,12 +151,18 @@ public function registerBundles(): iterable return []; } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { } } ); + // Since Symfony 8.1, core services (event_dispatcher, ...) are provided by ServicesBundle + if (class_exists(ServicesBundle::class)) { + $configs = ['services' => []] + $configs; + $container->registerExtension((new ServicesBundle())->getContainerExtension()); + } + $container->registerExtension(new FrameworkExtension()); $container->registerExtension(new TwigExtension()); $container->registerExtension(new LexikCronFileGeneratorExtension()); @@ -170,6 +176,10 @@ public function registerContainerConfiguration(LoaderInterface $loader) private function compileContainer(ContainerBuilder $container) { + if (class_exists(ServicesBundle::class)) { + (new ServicesBundle())->build($container); + } + (new TwigBundle())->build($container); $container->compile(); diff --git a/Tests/Functional/Bundle/DependencyInjection/BundleExtension.php b/Tests/Functional/Bundle/DependencyInjection/BundleExtension.php index b74af73..5fdd4c8 100644 --- a/Tests/Functional/Bundle/DependencyInjection/BundleExtension.php +++ b/Tests/Functional/Bundle/DependencyInjection/BundleExtension.php @@ -3,26 +3,11 @@ namespace Lexik\Bundle\CronFileGeneratorBundle\Tests\Functional\Bundle\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\HttpKernel\Kernel; +use Symfony\Component\DependencyInjection\Extension\Extension; -class BundleExtension extends Extension implements PrependExtensionInterface +class BundleExtension extends Extension { public function load(array $configs, ContainerBuilder $container): void { } - - public function prepend(ContainerBuilder $container): void - { - // Annotation must be disabled since this bundle doesn't use Doctrine - // The framework allows enabling/disabling them only since symfony 3.2 where - // doctrine/annotations has been removed from required dependencies - $annotationsEnabled = (int) Kernel::MAJOR_VERSION >= 3 && (int) Kernel::MINOR_VERSION >= 2; - if (!$annotationsEnabled) { - return; - } - - $container->prependExtensionConfig('framework', ['annotations' => ['enabled' => false]]); - } } diff --git a/Tests/Functional/ForwardCompatTestCaseTrait.php b/Tests/Functional/ForwardCompatTestCaseTrait.php deleted file mode 100644 index af32cdc..0000000 --- a/Tests/Functional/ForwardCompatTestCaseTrait.php +++ /dev/null @@ -1,34 +0,0 @@ -hasReturnType()) { - eval(' - namespace Lexik\Bundle\CronFileGeneratorBundle\Tests\Functional; - /** - * @internal - */ - trait ForwardCompatTestCaseTrait - { - protected function tearDown(): void - { - static::ensureKernelShutdown(); - static::$kernel = null; - } - } - '); -} else { - /** - * @internal - */ - trait ForwardCompatTestCaseTrait - { - protected function tearDown() - { - static::ensureKernelShutdown(); - static::$kernel = null; - } - } -} diff --git a/Tests/Functional/TestCase.php b/Tests/Functional/TestCase.php index 2e1ad1a..b04080b 100644 --- a/Tests/Functional/TestCase.php +++ b/Tests/Functional/TestCase.php @@ -8,8 +8,6 @@ abstract class TestCase extends WebTestCase { - use ForwardCompatTestCaseTrait; - protected static $client; protected static function createKernel(array $options = []): KernelInterface diff --git a/Tests/Functional/app/config/base_config.yml b/Tests/Functional/app/config/base_config.yml index 6321992..df85402 100644 --- a/Tests/Functional/app/config/base_config.yml +++ b/Tests/Functional/app/config/base_config.yml @@ -6,7 +6,6 @@ framework: twig: strict_variables: false default_path: './Resources/views' - exception_controller: null lexik_cron_file_generator: env_available: diff --git a/Tests/Functional/app/config/empty_cron_config.yml b/Tests/Functional/app/config/empty_cron_config.yml index 4bdf61d..8cac18c 100644 --- a/Tests/Functional/app/config/empty_cron_config.yml +++ b/Tests/Functional/app/config/empty_cron_config.yml @@ -6,7 +6,6 @@ framework: twig: strict_variables: false default_path: './Resources/views' - exception_controller: null lexik_cron_file_generator: env_available: From 1e40b8e85b49e7f9f2122fc0cbbf42e1f1692ed6 Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Mon, 2 Nov 2026 11:02:42 +0100 Subject: [PATCH 8/9] test: Clean up phpunit configuration --- phpunit.xml.dist | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1e2c06a..fb183e2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,10 +2,6 @@ - - + + From c2bc1971e0188ceaa923aa557cba6351166aa8d1 Mon Sep 17 00:00:00 2001 From: Romain MILLAN Date: Mon, 2 Nov 2026 11:02:42 +0100 Subject: [PATCH 9/9] doc: Document v2 requirements and upgrade path --- README.md | 10 ++++++++++ UPGRADE-2.0.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 UPGRADE-2.0.md diff --git a/README.md b/README.md index 0352e04..3740538 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,16 @@ LexikCronFileGeneratorBundle This symfony bundle provides cron file generation utilities. +Requirements +============ + +* PHP 8.1 or higher +* Symfony 6.4, 7.4 or 8.x +* Twig 3 + +Using an older PHP or Symfony version? Stick to the `v1.3.x` releases (latest: `v1.3.3`). +Upgrading from 1.x? See [UPGRADE-2.0.md](UPGRADE-2.0.md). + Installation ============ diff --git a/UPGRADE-2.0.md b/UPGRADE-2.0.md new file mode 100644 index 0000000..f4a7781 --- /dev/null +++ b/UPGRADE-2.0.md @@ -0,0 +1,45 @@ +UPGRADE FROM 1.x to 2.0 +======================= + +Requirements +------------ + +* PHP 8.1 or higher is required. +* Symfony 6.4, 7.4 or 8.x is required (support for Symfony 4.4, 5.4 and 6.0 to 6.3 is dropped). +* Twig 3 is required (support for Twig 2 is dropped), with a lower bound raised to + a version without known security advisories. +* Services are now loaded from PHP configuration files instead of XML ones. Service IDs + and the `Lexik\Bundle\CronFileGeneratorBundle\Cron\DumpFile` alias are unchanged. + +Command +------- + +* The command name and description are now declared with the `#[AsCommand]` attribute. + The command is still available as `lexik:cron:generate-file`. +* The `$name` argument of the `GenerateCronCommand` constructor has been removed. + + Before: + + ```php + new GenerateCronCommand($dumpFileFactory, 'app:my-cron-command'); + ``` + + After: + + ```php + new GenerateCronCommand($dumpFileFactory); + ``` + +* The `console.command` tag of the + `lexik_bundle_cron_file_generator.command.generate_cron_command` service no longer + carries a `command` option. If you extend `GenerateCronCommand` or re-tag the service + and relied on that option to set a custom name, declare it on your side, either with + `#[AsCommand]` on your subclass or with the `command` option of your own tag. + +Dependency conflicts +-------------------- + +The `conflict` section of `composer.json` excludes versions of some transitive Symfony +dependencies (`symfony/cache`, `symfony/http-foundation`, `symfony/http-kernel`, +`symfony/routing`) affected by known security advisories. These bounds are revised +when new advisories are published; `composer audit` runs in the CI as a safeguard.