10000 [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

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
* 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

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

$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

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


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