-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Hotfix - Lowercase custom sniff properties #2391
base: develop
Are you sure you want to change the base?
Conversation
…ustom properties Printing, escaping and sanitization trait helpers.
…on't trigger errors if allowed
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.
@dingo-d Thanks for setting up.
Note: The tests aren't actually testing the issue. This needs fixing.
There are some early returns that would make lowecasing not happen even if we passed the last parameter as true.
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.
Reviewed again. Left feedback.
Also looks like the tests are better than before, but still not completely targeted to this patch.
Basically, the phpcs:set
directives should only contain mixed/uppercase functions to test this patch.
I've just now realized that this helper is kinda doing too much on its own than its name suggests. The helper says it will merge the custom array, but can also flip the base array in the case the custom array is empty and the Would it make sense to rename it to something else? EDIT: Also, I think we can optimize it a bit by checking if both |
Hard "no" from me on this. The function merges two arrays, whether flipped or not etc, those are just implementation details for the merge, so functionality-wise, the name is perfectly fine. The fact that the Helper does not have a BC-promise, still doesn't mean that BC should be broken without good reason and there is no poignant reason to change the method name. |
@dingo-d Is this PR ready for its final review in the mean time ? Maybe dismiss "requested changes" once they have been addressed and ask for a new review via the interface when you think it is ready ? It's now not always clear whether or not it's time to review again. |
Co-authored-by: Juliette <[email protected]>
Co-authored-by: Juliette <[email protected]>
Ready for the final review @jrfnl 🙂 |
This PR will address the issue of handling mixed case function/method/class names when those are passed as custom-allowed properties in certain sniffs.
For instance, if we pass a custom sanitization function as a property
my_custom_sanitization
then it doesn't matter if we are callingMy_custom_Sanitization
orMY_CUSTOM_SANITIZATION
(or any combination of cases for that matter), PHP is case insensitive in that regard and the same function will be called.So the sniff shouldn't trigger on those variations (in some cases it will do that, as shown in PR #2370 which holds the fix for the custom escaping functions).
I've added tests to ensure that these changes will be caught.
I'm not 100% sure if I've covered all the cases, so any help in pointing out if I've missed something helps.