From 6c2460efbcb30187064f3a4bb8785df9e5a85f9d Mon Sep 17 00:00:00 2001 From: Jano Paetzold Date: Fri, 31 Jul 2026 10:21:37 +0200 Subject: [PATCH] Update: Bump the bundle to Symfony 8 / PHP 8.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Widen all symfony/* constraints to ^8.0, raise the PHP floor to ^8.4 (Symfony 8 requires PHP >= 8.4.1), and raise the CI PHP version to 8.4. Bump doctrine/doctrine-bundle to ^3.0 — v2.x has no Symfony 8 support. Six additional code fixes were needed to stay green on Symfony 8: - WebfactoryNewsletterRegistrationExtension::load(): add missing `: void` return type (Symfony 8 made ExtensionInterface::load() strict). - Callback constraint: array-key constructor syntax (['callback' => ...]) was removed; pass the callable directly instead. - Choice constraint: array options constructor was removed; use named arguments (choices:, multiple:, min:). - Doctrine test config: auto_generate_proxy_classes removed from DoctrineBundle 3's ORM configuration tree. - AppClassTemplatesTest: call $config->enableNativeLazyObjects(true) — Symfony 8 dropped the LazyGhostTrait that Doctrine ORM's old file-based proxy system relied on; PHP 8.4 native lazy objects replace it. - All four Foundry factories: PersistentProxyObjectFactory → PersistentObjectFactory — the proxy mechanism is gone in Symfony 8. --- .github/workflows/dependencies.yml | 2 +- .github/workflows/tests.yml | 2 +- composer.json | 40 +++++++++---------- ...factoryNewsletterRegistrationExtension.php | 2 +- .../TypeHasNewslettersElementTrait.php | 2 +- src/StartRegistration/EmailAddressType.php | 4 +- .../BlockedEmailAddressHashFactory.php | 4 +- tests/Factory/NewsletterFactory.php | 4 +- tests/Factory/PendingOptInFactory.php | 4 +- tests/Factory/RecipientFactory.php | 4 +- tests/Fixtures/config/doctrine.php | 1 - tests/Resources/AppClassTemplatesTest.php | 1 + 12 files changed, 34 insertions(+), 36 deletions(-) diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 09ff52d..e1745ca 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -7,7 +7,7 @@ on: pull_request: env: - PHP_VERSION: 8.3 + PHP_VERSION: 8.4 jobs: composer-require-checker: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a14374f..f7fcdd6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ on: pull_request: env: - PHP_VERSION: 8.3 + PHP_VERSION: 8.4 TEMP: ${{ github.workspace }}/tmp jobs: diff --git a/composer.json b/composer.json index 2337459..c4bc2df 100644 --- a/composer.json +++ b/composer.json @@ -4,38 +4,38 @@ "license": "MIT", "require": { - "php": "^8.2", + "php": "^8.4", "ext-mbstring": "*", "doctrine/collections": "^2.0", "doctrine/orm": "^3.0", "psr/log": "^3.0", "ramsey/uuid": "^4.0", - "symfony/config": "^7.0", - "symfony/console": "^7.0", + "symfony/config": "^8.0", + "symfony/console": "^8.0", "symfony/contracts": "^3.0", - "symfony/dependency-injection": "^7.0", - "symfony/doctrine-bridge": "^7.0", - "symfony/form": "^7.0", - "symfony/http-foundation": "^7.0", - "symfony/http-kernel": "^7.0", - "symfony/mailer": "^7.0", - "symfony/mime": "^7.0", - "symfony/options-resolver": "^7.0", - "symfony/routing": "^7.0", - "symfony/translation": "^7.0", - "symfony/validator": "^7.0", + "symfony/dependency-injection": "^8.0", + "symfony/doctrine-bridge": "^8.0", + "symfony/form": "^8.0", + "symfony/http-foundation": "^8.0", + "symfony/http-kernel": "^8.0", + "symfony/mailer": "^8.0", + "symfony/mime": "^8.0", + "symfony/options-resolver": "^8.0", + "symfony/routing": "^8.0", + "symfony/translation": "^8.0", + "symfony/validator": "^8.0", "twig/twig": "^3.0" }, "require-dev": { "doctrine/common": "^2.0 | ^3.0", - "doctrine/doctrine-bundle": "^2.4", + "doctrine/doctrine-bundle": "^3.0", "phpunit/phpunit": "^11.0", - "symfony/browser-kit": "^7.0", - "symfony/css-selector": "^7.0", - "symfony/framework-bundle": "^7.0", - "symfony/twig-bundle": "^7.0", - "symfony/yaml": "^7.0", + "symfony/browser-kit": "^8.0", + "symfony/css-selector": "^8.0", + "symfony/framework-bundle": "^8.0", + "symfony/twig-bundle": "^8.0", + "symfony/yaml": "^8.0", "zenstruck/foundry": "^2.8" }, diff --git a/src/DependencyInjection/WebfactoryNewsletterRegistrationExtension.php b/src/DependencyInjection/WebfactoryNewsletterRegistrationExtension.php index 93d1bb8..e72df10 100644 --- a/src/DependencyInjection/WebfactoryNewsletterRegistrationExtension.php +++ b/src/DependencyInjection/WebfactoryNewsletterRegistrationExtension.php @@ -9,7 +9,7 @@ class WebfactoryNewsletterRegistrationExtension extends Extension { - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); $loader->load('services.yml'); diff --git a/src/EditRegistration/TypeHasNewslettersElementTrait.php b/src/EditRegistration/TypeHasNewslettersElementTrait.php index 2c8949e..afdd0c0 100644 --- a/src/EditRegistration/TypeHasNewslettersElementTrait.php +++ b/src/EditRegistration/TypeHasNewslettersElementTrait.php @@ -21,7 +21,7 @@ protected function addNewslettersElementToForm(FormBuilderInterface $builder, bo $constraints = []; if (true === $recipientHasToChooseAtLeastOne) { - $constraints[] = new Choice(['min' => 1, 'choices' => $choices, 'multiple' => true]); + $constraints[] = new Choice(choices: $choices, multiple: true, min: 1); } $builder->add( diff --git a/src/StartRegistration/EmailAddressType.php b/src/StartRegistration/EmailAddressType.php index b9fa969..d084d5b 100644 --- a/src/StartRegistration/EmailAddressType.php +++ b/src/StartRegistration/EmailAddressType.php @@ -82,9 +82,7 @@ public function configureOptions(OptionsResolver $resolver): void 'constraints' => [ new NotBlank(), new Email(), - new Callback([ - 'callback' => $this->createEmailAddressIsAllowedToReceiveOptInEmailsConstraint(), - ]), + new Callback($this->createEmailAddressIsAllowedToReceiveOptInEmailsConstraint()), ], ]); } diff --git a/tests/Factory/BlockedEmailAddressHashFactory.php b/tests/Factory/BlockedEmailAddressHashFactory.php index dcfb0a5..5b05b5e 100644 --- a/tests/Factory/BlockedEmailAddressHashFactory.php +++ b/tests/Factory/BlockedEmailAddressHashFactory.php @@ -4,9 +4,9 @@ use DateTimeImmutable; use Webfactory\NewsletterRegistrationBundle\Entity\BlockedEmailAddressHash; -use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -final class BlockedEmailAddressHashFactory extends PersistentProxyObjectFactory +final class BlockedEmailAddressHashFactory extends PersistentObjectFactory { protected function defaults(): array { diff --git a/tests/Factory/NewsletterFactory.php b/tests/Factory/NewsletterFactory.php index 8f57c7c..51eb5c7 100644 --- a/tests/Factory/NewsletterFactory.php +++ b/tests/Factory/NewsletterFactory.php @@ -3,9 +3,9 @@ namespace Webfactory\NewsletterRegistrationBundle\Tests\Factory; use Webfactory\NewsletterRegistrationBundle\Tests\Entity\Dummy\Newsletter; -use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -final class NewsletterFactory extends PersistentProxyObjectFactory +final class NewsletterFactory extends PersistentObjectFactory { protected function defaults(): array { diff --git a/tests/Factory/PendingOptInFactory.php b/tests/Factory/PendingOptInFactory.php index 0d8e01f..02d7071 100644 --- a/tests/Factory/PendingOptInFactory.php +++ b/tests/Factory/PendingOptInFactory.php @@ -5,9 +5,9 @@ use DateTimeImmutable; use Webfactory\NewsletterRegistrationBundle\Entity\EmailAddress; use Webfactory\NewsletterRegistrationBundle\Tests\Entity\Dummy\PendingOptIn; -use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -final class PendingOptInFactory extends PersistentProxyObjectFactory +final class PendingOptInFactory extends PersistentObjectFactory { protected function defaults(): array { diff --git a/tests/Factory/RecipientFactory.php b/tests/Factory/RecipientFactory.php index 059d548..f8cbe6a 100644 --- a/tests/Factory/RecipientFactory.php +++ b/tests/Factory/RecipientFactory.php @@ -4,9 +4,9 @@ use Webfactory\NewsletterRegistrationBundle\Entity\EmailAddress; use Webfactory\NewsletterRegistrationBundle\Tests\Entity\Dummy\Recipient; -use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\PersistentObjectFactory; -final class RecipientFactory extends PersistentProxyObjectFactory +final class RecipientFactory extends PersistentObjectFactory { protected function defaults(): array { diff --git a/tests/Fixtures/config/doctrine.php b/tests/Fixtures/config/doctrine.php index ee9ec20..2f9755b 100644 --- a/tests/Fixtures/config/doctrine.php +++ b/tests/Fixtures/config/doctrine.php @@ -11,7 +11,6 @@ 'path' => '%kernel.cache_dir%/test.db', ], 'orm' => [ - 'auto_generate_proxy_classes' => true, 'resolve_target_entities' => [ NewsletterInterface::class => Newsletter::class, ], diff --git a/tests/Resources/AppClassTemplatesTest.php b/tests/Resources/AppClassTemplatesTest.php index f85f7ee..a46aa7b 100644 --- a/tests/Resources/AppClassTemplatesTest.php +++ b/tests/Resources/AppClassTemplatesTest.php @@ -48,6 +48,7 @@ protected function setUp(): void [__DIR__.'/../../Resources/app-class-templates'], isDevMode: true, ); + $config->enableNativeLazyObjects(true); $this->em = new EntityManager($connection, $config, $eventManager); }