PHPCS: switch to phpcsdevcs #259
Merged
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.
Ad discussed off GitHub.
Composer: require PHPCSDevCS
PHPCS: switch to using the PHPCSDev standard
This commit:
PSR2
ruleset in favour of thePHPCSDev
ruleset.The PHPCSDev ruleset checks the following:
testVersion
) is set to PHP 5.4, in line with therequire
ment for this package per thecomposer.json
file.PHPCSDev
/PSR12, the ruleset for the VariableAnalysis package will:Note: this complies with PSR12. PHPCSDev already had the blank line enforcement in place prior to this being forbidden via the PSR12 standard, which is why it excludes the rule.
Enforcing those needs additional (manual) adjustments to the codebase which can be done at a later point in time.
Refs:
CS: various minor whitespace fixes
Minimal changes needed to comply with the PSR12/PHPCSDev whitespace rules.
Most notably this commit adds a blank line between a PHP open tag and the namespace declaration as per the PSR12 file header rules.
CS: minor code restructuring [1]
The
VariableAnalysisSniff::processVariableAsSuperGlobal()
method checks a variable name against a fixed array of names usingin_array()
.To comply with the updated CS rules, each parameter in the function call would need to be placed on a new line and the function call itself as well, making this a very drawn out condition.
By restructuring the code to declare the array prior to the
in_array()
function call, this is no longer needed.Additional notes:
in_array()
call to a strict comparison by adding the third parameter and setting it totrue
.return
by removing the unnecessary condition and double return statements.I've not done so at this time, as it could also be considered to switch over to using the PHPCSUtils
Variables::isSuperglobal()
orVariables::isSuperglobalName()
methods in the future.Ref:
CS: minor code restructuring [2]
Similar to the previous commit, the
VariableAnalysisSniff::processVariableAsStaticDeclaration()
method declares an array within a function call.This commit moves the array declaration out of the function call and leverages a pre-defined array from the PHPCS native
Tokens
class to retrieve a number of the tokens (heredoc and nowdoc tokens).Note: this commit does not fix known shortcomings of this method as reported in #158 and #253.