Skip to content

[2.5][Form] solved dependency to ValidatorInterface, fix #11036 #11350

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

Closed
wants to merge 6 commits into from
Closed

[2.5][Form] solved dependency to ValidatorInterface, fix #11036 #11350

wants to merge 6 commits into from

Conversation

sebastianblum
Copy link

Q A
Bug fix? [yes]
New feature? [no]
BC breaks? [no]
Deprecations? [no]
Tests pass? [yes]
Fixed tickets #11036, #11345
License MIT
Doc PR

Since Symfony 2.5

The problem was that the form component has a hardcoded depencency to the deprecated validator component (api Version 2.4)
The pull request fixes the dependency to the validator component and supports now both implementations, apiVersion 2.5 and apiVersion 2.4 of the validator component.

@symfony Core Members
please review the changes https://github.com/sebastianblum/symfony/blob/0a1e9c208f8730219bebf89f6696b246a0c88da7/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php
I'm not sure if it was the right solution

@sebastianblum sebastianblum changed the title [Form] solved depency to ValidatorInterface [Form] solved dependency to ValidatorInterface, fix #11036 Jul 8, 2014
@@ -35,9 +37,23 @@ public static function getSubscribedEvents()
return array(FormEvents::POST_SUBMIT => 'validateForm');
}

public function __construct(ValidatorInterface $validator, ViolationMapperInterface $violationMapper)
/**
* @param ValidatorInterface $validator The validator requires an instance of ValidatorInterface
Copy link
Member

Choose a reason for hiding this comment

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

should be ValidatorInterface|LegacyValidatorInterface

@sebastianblum
Copy link
Author

@stof thank you for your feedback, I will update the code.

I mixed the comments with symfony version and symfony validator api version.

@sebastianblum
Copy link
Author

My suggestion for the new phpdoc comment is now

/**
     * @param  ValidatorInterface|LegacyValidatorInterface validator The validator requires an instance of ValidatorInterface
     *                                                               since validator apiVersion 2.5 instance of {@link Symfony\Component\Validator\Validator\ValidatorInterface}
     *                                                               until validator apiVersion 2.4 instance of {@link Symfony\Component\Validator\ValidatorInterface}
     */

Is this comment now clear enough? do you have a better wording?

@sebastianblum sebastianblum changed the title [Form] solved dependency to ValidatorInterface, fix #11036 [2.5][Form] solved dependency to ValidatorInterface, fix #11036 Jul 8, 2014
@stof
Copy link
Member

stof commented Jul 8, 2014

@sebastianblum I would just remove the param description entirely and keep only @param ValidatorInterface|LegacyValidatorInterface $validator

@sebastianblum
Copy link
Author

@stof I removed the param description, you are right, it is enough

{
if (!$validator instanceof ValidatorInterface && !$validator instanceof LegacyValidatorInterface) {
throw new \InvalidArgumentException('Validator must be instance of ValidatorInterface.');
Copy link
Member

Choose a reason for hiding this comment

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

the message should be changed to include the real interface names (as done in my previous comment)

@sebastianblum
Copy link
Author

I updated the Exception message

if ($validator instanceof ValidatorInterface) {
$this->validator = $validator;

/** @var \Symfony\Component\Validator\Mapping\ClassMetadata $metadata */
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of repeating this, you can leave were it was before, and add use instead of FQCN.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also IIRC proper phpdoc here should be:

use Symfony\Component\Validator\Mapping\ClassMetadata;

/** @var $metadata ClassMetadata */

Copy link
Member

Choose a reason for hiding this comment

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

the order is /** @var ClassMetadata $metadata */

@Tobion
Copy link
Contributor

Tobion commented Jul 11, 2014

Apart from cs 👍

@sebastianblum
Copy link
Author

I don't understand why the test is failing
https://travis-ci.org/symfony/symfony/jobs/29695829

can someone please help me

@jakzal
Copy link
Contributor

jakzal commented Jul 12, 2014

@sebastianblum can you rebase? The issue was fixed in master.

@stof
Copy link
Member

stof commented Jul 15, 2014

👍

@fabpot
Copy link
Member

fabpot commented Jul 15, 2014

@sebastianblum Can you rebase on master instead of merging? Thanks.

@sebastianblum
Copy link
Author

I hope I did it the rebase correct, didn't I?

@stof
Copy link
Member

stof commented Jul 15, 2014

yep, looks good.

👍

@fabpot
Copy link
Member

fabpot commented Jul 15, 2014

Isn't it something we need to merge in 2.5?

@stof
Copy link
Member

stof commented Jul 15, 2014

@fabpot it is

@sebastianblum
Copy link
Author

Yes, it is a bug fix for 2.5 and higher.

@stof
Copy link
Member

stof commented Jul 15, 2014

@fabpot could this be merged to be included in the 2.5.2 release ? Given that the PR is ready, it would be a shame to keep it pending until after the release while it breaks things for some users wanting to use the 2.5 API only

@fabpot
Copy link
Member

fabpot commented Jul 15, 2014

Yes, I'm going to merge it before next release.

@fabpot
Copy link
Member

fabpot commented Jul 15, 2014

Thank you @sebastianblum.

fabpot added a commit that referenced this pull request Jul 15, 2014
…11036 (Sebastian Blum)

This PR was submitted for the master branch but it was merged into the 2.5 branch instead (closes #11350).

Discussion
----------

[2.5][Form] solved dependency to ValidatorInterface, fix #11036

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| Fixed tickets | #11036, #11345
| License       | MIT
| Doc PR        |

Since Symfony 2.5

The problem was that the form component has a hardcoded depencency to the deprecated validator component (api Version 2.4)
The pull request fixes the dependency to the validator component and supports now both implementations, apiVersion 2.5 and apiVersion 2.4 of the validator component.

@symfony Core Members
please review the changes https://github.com/sebastianblum/symfony/blob/0a1e9c208f8730219bebf89f6696b246a0c88da7/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php
I'm not sure if it was the right solution

Commits
-------

705d67b [2.5][Form] solved dependency to ValidatorInterface, fix #11036
@sebastianblum
Copy link
Author

thank you @fabpot for merging.

fabpot added a commit that referenced this pull request Jul 16, 2014
…11036 (Sebastian Blum)

This PR was squashed before being merged into the 2.6-dev branch (closes #11350).

Discussion
----------

[2.5][Form] solved dependency to ValidatorInterface, fix #11036

| Q             | A
| ------------- | ---
| Bug fix?      | [yes]
| New feature?  | [no]
| BC breaks?    | [no]
| Deprecations? | [no]
| Tests pass?   | [yes]
| Fixed tickets | #11036, #11345
| License       | MIT
| Doc PR        |

Since Symfony 2.5

The problem was that the form component has a hardcoded depencency to the deprecated validator component (api Version 2.4)
The pull request fixes the dependency to the validator component and supports now both implementations, apiVersion 2.5 and apiVersion 2.4 of the validator component.

@symfony Core Members
please review the changes https://github.com/sebastianblum/symfony/blob/0a1e9c208f8730219bebf89f6696b246a0c88da7/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php
I'm not sure if it was the right solution

Commits
-------

ab765c9 [2.5][Form] solved dependency to ValidatorInterface, fix #11036
@webmozart
Copy link
Contributor

Thanks for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants