-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
Deprecate Remaining VIP sniffs #1410
Merged
jrfnl
merged 19 commits into
WordPress:develop
from
tomjn:vip-migrate-filesystem-write-disallow-sniff
Jul 16, 2018
+433
−110
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5585804
Deprecated the VIP FileSystemWritesDisallow Sniff and the Admin Bar …
tomjn 4ae8691
deprecate the VIP Order By Rand sniff
tomjn ea7493b
Deprecated the VIP RestrictedFunctions Sniff
tomjn df07c46
deprecated the VIP sniff RestrictedVariables
tomjn 907fd88
deprecates the VIP SessionFunctionsUsage sniff
tomjn d1272dd
Deprecated the VIP SessionVariableUsageSniff sniff
tomjn 7106b30
Deprecated the VIP sniff SuperGlobalInputUsageSniff
tomjn 42d1ef0
resolve PHPCBF formatting issues by adding commars and removing trail…
tomjn cafaf2a
update the VIP rulesets description to indicate that it's deprecated,…
tomjn 95581c0
Fixes for the VIP Sniff deprecations based on Juliettes review
tomjn 9faef43
Deprecated AbstractVariableRestrictionsSniff
tomjn a4db740
deprecated the has_html_open_tag method in Sniff class
tomjn 4b50df5
Remove VIP from the standard WP ruleset
tomjn ad1c014
unit test fixes
tomjn 9c1e44f
Fixes stray whitespace characters in the WP ruleset, and yoda conditi…
tomjn e3206b7
Apply spelling and grammar corrections to VIP deprecations
tomjn 20494c4
merges the xml comment in the VIP ruleset into the description
tomjn 50c3471
test the exclude parameter deprecation in the deprecated VIP sniff un…
tomjn 50c6d77
Updated the VIP deprecation notice in the readme to read better
tomjn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,25 @@ | |
* WordPress_Sniffs_WP_AlternativeFunctionsSniff. | ||
* The check for `eval()` now defers to the upstream Squiz.PHP.Eval sniff. | ||
* @since 0.13.0 Class name changed: this class is now namespaced. | ||
* | ||
* @deprecated 1.0.0 This sniff has been deprecated. | ||
* This file remains for now to prevent BC breaks. | ||
*/ | ||
class RestrictedFunctionsSniff extends AbstractFunctionRestrictionsSniff { | ||
|
||
/** | ||
* Keep track of whether the warnings have been thrown to prevent | ||
* the messages being thrown for every token triggering the sniff. | ||
* | ||
* @since 1.0.0 | ||
* | ||
* @var array | ||
*/ | ||
private $thrown = array( | ||
'DeprecatedSniff' => false, | ||
'FoundPropertyForDeprecatedSniff' => false, | ||
); | ||
|
||
/** | ||
* Groups of functions to restrict. | ||
* | ||
|
@@ -225,4 +241,35 @@ public function getGroups() { | |
); | ||
} | ||
|
||
/** | ||
* Process the token and handle the deprecation notices. | ||
* | ||
* @since 1.0.0 Added to allow for throwing the deprecation notices. | ||
* | ||
* @param int $stackPtr The position of the current token in the stack. | ||
* | ||
* @return void|int | ||
*/ | ||
public function process_token( $stackPtr ) { | ||
if ( false === $this->thrown['DeprecatedSniff'] ) { | ||
$this->thrown['DeprecatedSniff'] = $this->phpcsFile->addWarning( | ||
'The "WordPress.VIP.RestrictedFunctions" sniff has been deprecated. Please update your custom ruleset.', | ||
0, | ||
'DeprecatedSniff' | ||
); | ||
} | ||
|
||
if ( ! empty( $this->exclude ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A unit test should be added to test that the deprecated property warning is thrown correctly. |
||
&& false === $this->thrown['FoundPropertyForDeprecatedSniff'] | ||
) { | ||
$this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning( | ||
'The "WordPress.VIP.RestrictedFunctions" sniff has been deprecated. Please update your custom ruleset.', | ||
0, | ||
'FoundPropertyForDeprecatedSniff' | ||
); | ||
} | ||
|
||
return parent::process_token( $stackPtr ); | ||
} | ||
|
||
} |
Oops, something went wrong.
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.
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.
A unit test should be added to test that the deprecated property warning is thrown correctly.