From 7b6636d153f11900e338cc776ff0ad3240f0a0d4 Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Wed, 20 Dec 2023 23:44:43 +0100 Subject: [PATCH] [AllBundles] Fix symfony 6.4 deprecations --- .php-cs-fixer.dist.php | 4 +++- .../AdminBundle/Tests/Entity/GroupTest.php | 23 +++++++++---------- .../Service/Translator/Translator.php | 5 +++- .../TranslatorBundle/Tests/app/AppKernel.php | 9 ++++++++ .../Tests/app/config/config.yml | 2 ++ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f49e85e088..3bf8957764 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -5,8 +5,10 @@ ->exclude([ 'src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle', 'src/Kunstmaan/CookieBundle/Resources/skeleton', - 'node_modules' + 'node_modules', ]) + // Temporary exclude translator class to avoid removing warmUp parameter docblock which is needed to silence a deprecation. + ->notPath('src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php') ; return (new PhpCsFixer\Config()) diff --git a/src/Kunstmaan/AdminBundle/Tests/Entity/GroupTest.php b/src/Kunstmaan/AdminBundle/Tests/Entity/GroupTest.php index 8fd8f6e844..37056b2c27 100644 --- a/src/Kunstmaan/AdminBundle/Tests/Entity/GroupTest.php +++ b/src/Kunstmaan/AdminBundle/Tests/Entity/GroupTest.php @@ -133,18 +133,13 @@ public function testValidateGroupWithoutRole() $group = new Group('test'); $validatorBuilder = Validation::createValidatorBuilder(); - if (method_exists(ValidatorBuilder::class, 'setDoctrineAnnotationReader')) { - $validatorBuilder - ->enableAnnotationMapping(true) - ->addDefaultDoctrineAnnotationReader() - ; + if (method_exists(ValidatorBuilder::class, 'enableAttributeMapping')) { + $validatorBuilder->enableAttributeMapping(); } else { - $validatorBuilder - ->enableAnnotationMapping() - ; + $validatorBuilder->enableAnnotationMapping(); } - $validator = $validatorBuilder->getValidator(); + $violations = $validator->validate($group); $this->assertCount(1, $violations); @@ -155,9 +150,13 @@ public function testValidateGroupWithRole() $group = new Group('test'); $group->addRole(new Role('role')); - $validator = Validation::createValidatorBuilder() - ->enableAnnotationMapping(method_exists(ValidatorBuilder::class, 'setDoctrineAnnotationReader') ? true : null) - ->getValidator(); + $validatorBuilder = Validation::createValidatorBuilder(); + if (method_exists(ValidatorBuilder::class, 'enableAttributeMapping')) { + $validatorBuilder->enableAttributeMapping(); + } else { + $validatorBuilder->enableAnnotationMapping(); + } + $validator = $validatorBuilder->getValidator(); $violations = $validator->validate($group); diff --git a/src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php b/src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php index e2f2aafad4..8cfdddce74 100644 --- a/src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php +++ b/src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php @@ -32,7 +32,10 @@ public function addDatabaseResources() } } - public function warmUp($cacheDir): array + /** + * @param string|null $buildDir + */ + public function warmUp(string $cacheDir /* , string $buildDir = null */): array { return []; } diff --git a/src/Kunstmaan/TranslatorBundle/Tests/app/AppKernel.php b/src/Kunstmaan/TranslatorBundle/Tests/app/AppKernel.php index e0542d8a85..1ef2d74d18 100644 --- a/src/Kunstmaan/TranslatorBundle/Tests/app/AppKernel.php +++ b/src/Kunstmaan/TranslatorBundle/Tests/app/AppKernel.php @@ -85,6 +85,15 @@ public function registerContainerConfiguration(LoaderInterface $loader): void if (class_exists(Passport::class) && !class_exists(ChainUserChecker::class)) { $containerBuilder->prependExtensionConfig('security', ['enable_authenticator_manager' => true]); } + + // Only set these config options on 6.2+ + if (class_exists(ChainUserChecker::class)) { + $containerBuilder->prependExtensionConfig('framework', [ + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + 'annotations' => ['enabled' => false], + ]); + } }); } diff --git a/src/Kunstmaan/TranslatorBundle/Tests/app/config/config.yml b/src/Kunstmaan/TranslatorBundle/Tests/app/config/config.yml index cf3a036638..a98aed573e 100644 --- a/src/Kunstmaan/TranslatorBundle/Tests/app/config/config.yml +++ b/src/Kunstmaan/TranslatorBundle/Tests/app/config/config.yml @@ -7,6 +7,8 @@ framework: router: resource: "%kernel.project_dir%/config/routing.yml" utf8: true + validation: + email_validation_mode: html5 kunstmaan_admin: website_title: 'PHPUnit test app'