-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Move validation checking functionality to dedicated ValidationHelper, implement PHPCSUtils + other improvements #2264
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GaryJones
approved these changes
Jun 23, 2023
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 `is_validated()` utility method is only used by a small set of sniffs, so is better placed in a dedicated class. This commit moves the `is_validated()` method to the new `WordPressCS\WordPress\Helpers\ValidationHelper` class and starts using that class in the relevant sniffs. The method has been made stand-alone and now expects the `$phpcsFile` to be passed to it. The method signature has changed from `protected` to `public static`. Related to 1465 This method will be tested via the `WordPress.Security.ValidatedSanitizedInput` sniff (via pre-existing tests).
... to allow for adding additional test case files testing specific (parse error) situations.
... in particular testing the defensive coding which is in place in the helper method.
Includes bug fix as the function name comparison was not done in a case-insensitive manner. Tested by adjusting one of the existing tests.
…eters Includes tests in the `WordPress.Security.ValidatedSanitizedInput` test file.
…ich may look like function calls Includes test in the `WordPress.Security.ValidatedSanitizedInput` test file.
…llables which look like function calls This already is handled via the `PassedParameters` class. Includes test in the `WordPress.Security.ValidatedSanitizedInput` test file.
Includes extra test for additionally added defensive coding.
jrfnl
force-pushed
the
feature/move-is-validated-and-improve
branch
from
June 23, 2023 20:18
5f7b100
to
946dffb
Compare
dingo-d
approved these changes
Jun 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Move validation checking functionality to dedicated ValidationHelper
The
is_validated()
utility method is only used by a small set of sniffs, so is better placed in a dedicated class.This commit moves the
is_validated()
method to the newWordPressCS\WordPress\Helpers\ValidationHelper
class and starts using that class in the relevant sniffs.The method has been made stand-alone and now expects the
$phpcsFile
to be passed to it.The method signature has changed from
protected
topublic static
.Related to #1465
This method will be tested via the
WordPress.Security.ValidatedSanitizedInput
sniff (via pre-existing tests).Security/ValidatedSanitizedInput: rename test case file
... to allow for adding additional test case files testing specific (parse error) situations.
ValidationHelper::is_validated(): add some extra tests
... in particular testing the defensive coding which is in place in the helper method.
ValidationHelper::is_validated(): implement PHPCSUtils
ValidationHelper::is_validated(): move inline array to property [1]
ValidationHelper::is_validated(): move inline array to property [2]
Includes bug fix as the function name comparison was not done in a case-insensitive manner.
Tested by adjusting one of the existing tests.
ValidationHelper::is_validated(): extract some duplicate code to a separate method
ValidationHelper::is_validated(): add note about PHP 7.4 arrow functions
ValidationHelper::is_validated(): add support for PHP 8.0 named parameters
Includes tests in the
WordPress.Security.ValidatedSanitizedInput
test file.ValidationHelper::is_validated(): don't examine PHP 8.0 attributes which may look like function calls
Includes test in the
WordPress.Security.ValidatedSanitizedInput
test file.ValidationHelper::is_validated(): don't examine PHP 8.1 first call callables which look like function calls
This already is handled via the
PassedParameters
class.Includes test in the
WordPress.Security.ValidatedSanitizedInput
test file.ValidationHelper::is_validated(): various minor tweaks
Includes extra test for additionally added defensive coding.