8000 [Validator] Deprecate `ValidatorBuilder::enableAnnotationMapping()` and `ValidatorBuilder::disableAnnotationMapping()` by alexandre-daubois · Pull Request #51426 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Deprecate ValidatorBuilder::enableAnnotationMapping() and ValidatorBuilder::disableAnnotationMapping() #51426

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 clic 8000 king “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

Conversation

alexandre-daubois
Copy link
Member
@alexandre-daubois alexandre-daubois commented Aug 18, 2023
Q A
Branch? 6.4
Bug fix? no
New feature? no
Deprecations? yes
Tickets Part of #51381
License MIT
Doc PR -

Required by #51425

…nd `ValidatorBuilder::disableAnnotationMapping()`
@alexandre-daubois alexandre-daubois force-pushed the validator-annotation-deprecations branch from dee9977 to 9fa9c32 Compare August 18, 2023 13:17
UPGRADE-6.4.md Outdated
@@ -156,4 +156,6 @@ Validator
* Deprecate Doctrine annotations support in favor of native attributes
* Deprecate passing an annotation reader to the constructor signature of `AnnotationLoader`
* Deprecate `ValidatorBuilder::setDoctrineAnnotationReader()`
* Deprecate `ValidatorBuilder::addDefaultDoctrineAnnotationReader()`
* Deprecate `ValidatorBuilder::addDefaultDoctrineAnnotationReader()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing backtick

public function testExpectDeprecationWhenDisablingAnnotationMapping()
{
$this->expectDeprecation('Since symfony/validator 6.4: Method "Symfony\Component\Validator\ValidatorBuilder::disableAnnotationMapping()" is deprecated, use "disableAttributeMapping()" instead.');
$this->builder->disableAnnotationMapping();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not loose the assertion about the fluent API that we had before

@@ -81,7 +81,7 @@ public function testAddMethodMappings()
*/
public function testEnableAnnotationMappingWithDefaultDoctrineAnnotationReader()
{
$this->assertSame($this->builder, $this->builder->enableAnnotationMapping());
$this->assertSame($this->builder, $this->builder->enableAttributeMapping());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is really about annotation mapping. So I would rather expect both deprecations in it than changing method

@@ -102,7 +102,7 @@ public function testEnableAnnotationMappingWithCustomDoctrineAnnotationReader()
{
$reader = $this->createMock(Reader::class);

$this->assertSame($this->builder, $this->builder->enableAnnotationMapping());
$this->assertSame($this->builder, $this->builder->enableAttributeMapping());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

*
* @return $this
*/
public function enableAttributeMapping(): static
{
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot enable annotation mapping after setting a custom metadata factory. Configure your metadata factory instead.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this exception message should be updated

@@ -344,7 +369,7 @@ public function getLoaders(): array
$loaders[] = new StaticMethodLoader($methodName);
}

if ($this->enableAnnotationMapping) {
if ($this->enableAttributeMapping) {
$loaders[] = new AnnotationLoader($this->annotationReader);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't rename the loader class as well, this work is incomplete

Copy link
Member
@xabbuh xabbuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to update the FrameworkExtension.

@alexandre-daubois
Copy link
Member Author

Alright, I thought it was the way to deal with the CI that misses some not-yet-merged methods. Closing in favor of #51425, I addressed your comments there 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0