-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fixed ValidatorExtension to work with the 2.5 Validation API #11645
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
Conversation
} else { | ||
throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); | ||
throw new UnexpectedTypeException($validator, 'Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Symfony, we use the SPL InvalidArgumentException directly in places were we had to remove the typehint to support several classes because of a BC layer. I'm not sure we should switch to the Validator UnexpectedTypeException here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you mean.. UnexpectedTypeException extends InvalidArgumentException, what's the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, what I mean is that we generally don't use component exceptions for these cases (we use exception just because we cannot reproduce the behavior of PHP for unsatisfied typehints)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do use UnexpectedTypeExceptions quite often for that. At least in a couple of components (including Validator).
👍 |
ping @symfony/deciders |
👍 |
…ation API (webmozart) This PR was merged into the 2.5 branch. Discussion ---------- [Form] Fixed ValidatorExtension to work with the 2.5 Validation API | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11606 | License | MIT | Doc PR | - The ValidatorExtension::loadTypeGuesser() method used to fail because the method `getMetadataFactory()` does not exist anymore on the new `ValidatorInterface`. This was fixed easily, because `ValidatorInterface` now extends `ClassMetadataFactory`. Commits ------- ff74f4e [Form] Fixed ValidatorExtension to work with the 2.5 Validation API
The ValidatorExtension::loadTypeGuesser() method used to fail because the method
getMetadataFactory()
does not exist anymore on the newValidatorInterface
. This was fixed easily, becauseValidatorInterface
now extendsClassMetadataFactory
.