Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AllBundles] Fix symfony 6.4 deprecations #3324

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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