Skip to content

Conversation

@xabbuh
Copy link
Member

@xabbuh xabbuh commented Dec 12, 2025

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues part of #62669
License MIT

$metadata = $this->getMockBuilder(ClassMetadata::class)->setConstructorArgs([''])->onlyMethods(['addPropertyConstraint'])->getMock();
$this->validator->expects($this->any())->method('getMetadataFor')->willReturn($metadata);
$this->validator->expects($this->any())->method('validate')->willReturn(new ConstraintViolationList());
$this->validator = (new ValidatorBuilder())->getValidator();
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the validator is protected, someone could add expections $this->validator->method(...) when using the trait.

So is this change considered as a BC break ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I won't consider this a BC break as the type of the property is ValidatorInterface. In other places where we communicated the type to be MockObject I kept it.

Copy link
Member

Choose a reason for hiding this comment

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

Would keeping the mock be problematic? Symfony is widely used enough for someone to be affected by this ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, we can keep it as is by not using the trait internally anymore :) we might want to deprecate it in 8.1

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