Skip to content

Commit

Permalink
[AllBundles] Fix symfony 6.4 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
acrobat committed Dec 21, 2023
1 parent cc6fef5 commit 7b6636d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
23 changes: 11 additions & 12 deletions src/Kunstmaan/AdminBundle/Tests/Entity/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}
Expand Down
9 changes: 9 additions & 0 deletions src/Kunstmaan/TranslatorBundle/Tests/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
]);
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/Kunstmaan/TranslatorBundle/Tests/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 7b6636d

Please sign in to comment.