-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] moved data trimming logic of TrimListener into StringUtil #14146
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
Why put into |
@dosten I also thought so but I decided to put into a new class because FormUtil is singular form. Should this code be moved into FormUtil?
|
/** | ||
* Returns the trimmed data. | ||
* | ||
* @param mixed $data |
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 should only accept a string
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, this would force to keep the is_string check in TrimListener though
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.
which is way better in terms of single responsibility.
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.
why would this method handle non-strings here. doesn't make sense. it's not even documented that non-strings are returned as-is.
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.
also this will allow us to add scalar type hints later for php 7.
5bfeec3
to
f222c6d
Compare
I've just updated PR. Now, StringUtil does not concern argument type. |
use Symfony\Component\Form\Util\StringUtil; | ||
|
||
/** | ||
* @author Bernhard Schussek <bschussek@gmail.com> |
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.
test classes dont have this annotation
f222c6d
to
b03f7b0
Compare
@issei-m As you just moved code around, keeping @webmozart as the author is the best. |
@xabbuh Thanks. Well then, all issues were resolved. |
About the authorship, you should include yourself as author as well. I'd be pretty confused if I'd find myself as only author of a class that I had never seen before ;) I think this is fine, but it can't be merged into 2.7 as that branch is feature frozen. |
@webmozart Thanks for your advice. I'll try to open a new PR soon. |
…StringUtil (issei-m) This PR was squashed before being merged into the 2.8 branch (closes #14660). Discussion ---------- [Form] moved data trimming logic of TrimListener into StringUtil | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - I introduced this PR at #14146, but I didn't make it on time for 2.7 feature freeze. So I'm opening the new PR for 2.8. Following is my first introduction: > In the small job which needs not to build a form (e.g. just process a value gotten from Request), I want to reuse the trim logic. @dosten @Tobion @xabbuh @stof @webmozart Thanks for all your feedback. I have fixed all issues mentioned on #14146. Please re-consider it. Commits ------- f42c777 [Form] moved data trimming logic of TrimListener into StringUtil
In the small job which needs not to build a form (e.g. just process a value gotten from Request), I want to reuse the trim logic.