-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] add guess pattern #3927
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
[Form] add guess pattern #3927
Conversation
You need to revert change of permissions. |
@@ -16,6 +16,7 @@ |
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.
please revert all permission changes
Some file permissions have been changed in your commit, they should be reverted |
@@ -68,6 +68,13 @@ public function guessMinLength($class, $property) | |||
}); | |||
} | |||
|
|||
public function guessPattern($class, $property) |
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.
You should add {@inheritDoc}
.
What do you mean by "please revert all permission changes" because i did not change any permissions by myself :/ |
@ruian which OS are you using ? If you are on windows, you should configure git to ignore file permissions (as Windows cannot handle them). Msysgit should do it by default but some other tools don't configure git this way: http://stackoverflow.com/questions/6476513/git-file-permissions-on-windows-7 |
@stof i'm on linux but i did not change any chmod or chown since a clone the repo |
@ruian In your pull request, you are changing file permissions from 644 to 755. This is what should be reverted |
public function guessPatternForConstraint(Constraint $constraint) | ||
{ | ||
switch (get_class($constraint)) { | ||
case 'Symfony\Component\Validator\Constraints\MaxLength': |
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.
Don't you mean Regex
?
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.
Fixed
Can you squash your commits ? |
you mean rebase ? If it the case i have never test |
Look at the doc at the end of the page ;) |
Yep i will look at it |
@stof I squash my commits. It's ok ? |
It looks good to me. @fabpot @bschussek ready for the final review @ruian could you send PRs to https://github.com/doctrine/DoctrineMongoDBBundle https://github.com/doctrine/DoctrinePHPCRBundle and https://github.com/doctrine/DoctrineCouchDBBundle to add the new method ? |
yep sure |
|
||
$type = $typeGuess ? $typeGuess->getType() : 'text'; | ||
|
||
$maxLength = $maxLengthGuess ? $maxLengthGuess->getValue() : null; | ||
$minLength = $minLengthGuess ? $minLengthGuess->getValue() : null; |
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.
this is wrong... as getValue()
can return null
. Could you revert and add a comment here (which I should have done in first place).
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.
Yep sure i revert it as you wish
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.
it is needed as you code is broken in case of a null value
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.
It's fixed now, i will squash and make some PR into others Repo who depends of this
@stof I made all Doctrine PRs to respect this new one |
@bschussek any comments on this PR ? |
{ | ||
switch (get_class($constraint)) { | ||
case 'Symfony\Component\Validator\Constraints\Regex': | ||
return new PatternGuess($constraint->pattern, Guess::LOW_CONFIDENCE); |
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.
You should use ValueGuess instead.
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.
You should put MEDIUM_CONFIDENCE here. A second case statement should be added for the MinLength constraint. If you check FormFactory, a "pattern" constraint is created there for min length - these two functionalities must now be merged.
Hi @ruian, thank you for the PR! I added some comments and hope you can check them soon. If you need help, just drop a message. |
@bschussek thx for your comments, i will do this as soon as possible |
@bschussek should i remove all call to guessMinLength ? |
{ | ||
switch (get_class($constraint)) { | ||
case 'Symfony\Component\Validator\Constraints\Regex': | ||
return new ValueGuess($constraint->pattern, Guess::MEDIUM_CONFIDENCE ); |
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.
The pattern for the MinLength constraint should be added here as well (with LOW_CONFIDENCE).
@ruian Yes, guessMinLength() can be removed entirely (and all references to it). |
ping @bschussek is it good like this ? |
{ | ||
$guesser = $this; | ||
|
||
return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { | ||
return $guesser->guessMinLengthForConstraint($constraint); | ||
return $guesser->guessPatternConstraint($constraint); |
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.
Please keep the "For" in the method name.
@bschussek @vicb i think it's good now, and i think i understood the diff between Size and SizeLength Constraint ValueGuess (One is for numeric and the other for string). It was not clear in my mind when i made the change. But now it's okay |
* @param string $class The fully qualified class name | ||
* @param string $property The name of the property to guess for | ||
* | ||
* @return Guess The guess for the pattern |
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.
Please add the comment to FormTypeGuesserInterface and use {@inheritdoc} in all implementing classes.
Please squash the commits once you're done. You should also update the CHANGELOG. |
This needs to be rebased with also as it currently wont merge. (git fetch; git rebase origin/master). |
something is strange with this PR .. why is it marked as merged by @ruian? and why are there no changes in the diff? and why was it labeled as no BC break? |
@lsmith77 You are right, this should be marked as BC break. I originally thought that guessMinLength() was only introduced after 2.0, but it was not. I will update the documentation. |
@bschussek do you want i create a new PR for the changelog ? |
@ruian I already did this. Thanks anyway! |
Commits ------- d9e142b [Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser Discussion ---------- [Form] Restored and deprecated method `guessMinLength` in FormTypeGuesser Bug fix: yes Feature addition: no Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: - Todo: -  This is a follow-up PR to #4077 (see comments in #3927 for reference).
Commits ------- f7200e4 [Form] added method `guessPattern` to FormTypeGuesserInterface Discussion ---------- [Form] add guess pattern Bug fix: no Feature addition: yes Backwards compatibility break: no Symfony2 tests pass: yes Fixes the following tickets: symfony#3766 Todo: - Due to some trouble when rebase my previous PR i open a new one with Master merged Refs PR: symfony#3927 --------------------------------------------------------------------------- by fabpot at 2012-04-23T10:25:57Z @vicb @bschussek ok for you? --------------------------------------------------------------------------- by bschussek at 2012-04-23T10:26:51Z please do also rephrase the commit message to something clearer, like [Form] added method `guessPattern` to FormTypeGuesserInterface --------------------------------------------------------------------------- by bschussek at 2012-04-23T10:27:35Z Otherwise this looks good :) --------------------------------------------------------------------------- by ruian at 2012-04-23T10:29:18Z every changes done
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3766
Todo: -