-
-
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
NamingConventions/ValidVariableName: implement PHPCSUtils and support modern PHP #2192
Merged
dingo-d
merged 10 commits into
develop
from
feature/validvariablename-phpcsutils-and-modern-php
Jan 11, 2023
Merged
NamingConventions/ValidVariableName: implement PHPCSUtils and support modern PHP #2192
dingo-d
merged 10 commits into
develop
from
feature/validvariablename-phpcsutils-and-modern-php
Jan 11, 2023
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
Synced in relevant changes as made upstream in the following commit: * squizlabs/PHP_CodeSniffer@beeb36f - Making sure the sniff works correctly with PHP 7.4+ typed properties.
When a text string with interpolated variables contained a variable on the `$wordpress_mixed_case_vars` list, any variables found in the text string _after_ it would not be examined or flagged. Fixed now. Includes test proving the bug and safeguarding the fix.
Includes minor efficiency tweak. Includes adding a test for the OO property verification, which was so far untested.
Includes minor efficiency tweaks.
Improve and stabilize the retrieval of embedded variables by: 1. Using the `TextStrings::getEmbed()` method to retrieve all embedded expressions. 2. Subsequently still using the regex to match variables within embedded expressions, but with an improved regex. - Fixed the `\x7f-\xff` range to `\x80-\xff` (was originally wrong in the PHP manual). - Only match a variable in braces - `${foo}` - when the braces are balanced. Note: this syntax is deprecated as per PHP 8.2, but that's not the concern of this sniff. - Capture the variable name in a named match. Includes tests.
…nctions ... to safeguard those are handled correctly.
…object operator Check for both the `T_OBJECT_OPERATOR` as well as the `T_NULLSAFE_OBJECT_OPERATOR`. Includes unit tests.
... to safeguard variables found in those are handled correctly.
... which tests code previously untested.
GaryJones
approved these changes
Jan 10, 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.
✅
dingo-d
approved these changes
Jan 11, 2023
dingo-d
deleted the
feature/validvariablename-phpcsutils-and-modern-php
branch
January 11, 2023 09:11
19 tasks
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.
NamingConventions/ValidVariableName: sync with upstream
Synced in relevant changes as made upstream in the following commit:
NamingConventions/ValidVariableName: bug fix
When a text string with interpolated variables contained a variable on the
$wordpress_mixed_case_vars
list, any variables found in the text string after it would not be examined or flagged.Fixed now.
Includes test proving the bug and safeguarding the fix.
NamingConventions/ValidVariableName: implement PHPCSUtils [1]
Includes minor efficiency tweak.
Includes adding a test for the OO property verification, which was so far untested.
NamingConventions/ValidVariableName: implement PHPCSUtils [2]
Includes minor efficiency tweaks.
NamingConventions/ValidVariableName: implement PHPCSUtils [3]
Improve and stabilize the retrieval of embedded variables by:
TextStrings::getEmbed()
method to retrieve all embedded expressions.\x7f-\xff
range to\x80-\xff
(was originally wrong in the PHP manual).${foo}
- when the braces are balanced.Note: this syntax is deprecated as per PHP 8.2, but that's not the concern of this sniff.
Includes tests.
NamingConventions/ValidVariableName: add tests with PHP 7.4+ arrow functions
... to safeguard those are handled correctly.
NamingConventions/ValidVariableName: allow for the PHP 8.0+ nullsafe object operator
Check for both the
T_OBJECT_OPERATOR
as well as theT_NULLSAFE_OBJECT_OPERATOR
.Includes unit tests.
NamingConventions/ValidVariableName: add tests with PHP 8.1+ enums
... to safeguard variables found in those are handled correctly.
NamingConventions/ValidVariableName: add extra test
... which tests code previously untested.
NamingConventions/ValidVariableName: minor documentation improvement