Skip to content

[Validator] fixed duplicate constraints with parent class interfaces #19580

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

Merged
merged 1 commit into from
Aug 23, 2016

Conversation

dmaicher
Copy link
Contributor

@dmaicher dmaicher commented Aug 9, 2016

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19516
License MIT
Doc PR -

This fixes #19516

if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
if (
'Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name ||
$parent && $parent->implementsInterface($interface->name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it work for a child of a child?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should work 😉 No matter at which level (starting at the parent then going upwards to the parent of the parent etc.) the interface is implemented this condition will be true.

Or what exactly do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean I was wondering about the pertinence of adding a test for it but you look pretty sure :)

@dmaicher dmaicher force-pushed the issue-19516 branch 2 times, most recently from f411c08 to 7b4d8b1 Compare August 9, 2016 19:57
foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name) {
if ('Symfony\Component\Validator\GroupSequenceProviderInterface' === $interface->name
|| $parent && $parent->implementsInterface($interface->name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep the condition in a single line, but add parenthesis to make precedence explicit.

Copy link
Member

Choose a reason for hiding this comment

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

We don't enforce line length in Symfony, so keeping everything on one line is the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it 👍

@dmaicher
Copy link
Contributor Author

@webmozart you are probably the most qualified to say if this fix is correct? 😊

@dmaicher
Copy link
Contributor Author

@fabpot @stof @nicolas-grekas who could have a look at this? 😊

@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

fabpot commented Aug 23, 2016

Thank you @dmaicher.

@fabpot fabpot merged commit fb36c5a into symfony:2.7 Aug 23, 2016
fabpot added a commit that referenced this pull request Aug 23, 2016
…interfaces (dmaicher)

This PR was merged into the 2.7 branch.

Discussion
----------

[Validator] fixed duplicate constraints with parent class interfaces

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19516
| License       | MIT
| Doc PR        | -

This fixes #19516

Commits
-------

fb36c5a [Validator] fixed duplicate constraints with parent class interfaces
This was referenced Sep 2, 2016
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.

7 participants