Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Aug 15, 2014

Conversation

webmozart
Copy link
Contributor

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.

} 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');
Copy link
Member

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

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 don't understand what you mean.. UnexpectedTypeException extends InvalidArgumentException, what's the problem?

Copy link
Member

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)

Copy link
Contributor Author

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).

@stof
Copy link
Member

stof commented Aug 13, 2014

👍

@webmozart
Copy link
Contributor Author

ping @symfony/deciders

@nicolas-grekas
Copy link
Member

👍

@webmozart webmozart merged commit ff74f4e into symfony:2.5 Aug 15, 2014
webmozart added a commit that referenced this pull request Aug 15, 2014
…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
@webmozart webmozart deleted the issue11606 branch August 15, 2014 09:43
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.

3 participants