Add the base rulesets #7
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.
This PR adds the base rulesets for PHPCSUtils.
It also puts QA in place to:
Commit details:
PHPCSUtils: add the ruleset file
This will allow PHPCS to recognize PHPCSUtils as if it were an external PHPCS standard and handle the autoloading of all PHPCSUtils files automatically when using PHPCS 3+.
External standards using PHPCSUtils don't even need to add
<rule ref="PHPCSUtils"/>
to their own ruleset.All that is needed is for the PHPCSUtils standard to be in the PHPCS
installed_paths
which - for Composer based installs - will automatically be taken care of by the DealerDirect Composer PHPCS plugin which is arequire
d dependency for this package.PHPCSUtils: add an (optional) autoloader
... for external standards which have their own test suite.
In PHPCS > 3.0.2+, when using the PHPCS native test suite, the files from PHPCSUtils will automatically load correctly.
However, when using a custom test suite, this will generally not be the case.
Requiring the
phpcsutils-autoload.php
file in the test runner bootstrap file will fix this.Alternatively, if only Composer-based installs are supported, loading the
vendor/autoload.php
file generated by Composer should also fix this.Notes:
phpcsutils-autoload.php
instead ofautoload.php
to prevent potential confusion with other autoload files.Also see: Autoload relative paths first to avoid confusion with files from the global include path squizlabs/PHP_CodeSniffer#2751
PHPCS23Utils: add support for PHPCS 2.x
This commit is two-fold:
It enhances the
phpcsutils-autoload.php
file to contain class aliases to translate the relevant PHPCS 3.x class names to PHPCS 2.x class names which, in effect, allows for the PHPCSUtils utilities to be used in both PHPCS 2.x as well as PHPCS 3.x.It adds a
PHPCS23Utils
ruleset with onePHPCS23Utils.Load.LoadUtils
sniff.The only thing this standard does is trigger the PHPCSUtils autoload file in PHPCS 2.x.
This standard will not include any utilities or real sniffs. It is just in place to enable support for PHPCS 2.x in an as-simple-as-possible manner.
🔧 QA: lint the ruleset XML files
🔧 QA: lint PHP files in this repo
🔧 QA: add code style check for the code in this repo
This:
PHPCSDev
ruleset to check the code style of code in this repo, with a few, very select, exclusions.composer.json
file to check the code of the repo.phpcs.xml.dist
file by ignoring the typical overload files.Important notes:
compose require
is done directly in the Composer script rather than in therequire-dev
section as the PHPCS requirements for thePHPCSDevTools
package can conflict with the PHPCS requirements of this package.The CS check for this package should always be run on a recent PHPCS version to get the benefit of new sniffs, while the Utils themselves are - and should be - compatible with a wider range of PHPCS versions.
Using the above "trick" runs into issues when trying to remove the package on Travis due to some phantom uncommitted changes in the
vendor/phpcstandards/phpcsdevtools
directory. So, a separate script is used for Travis which doesn'tcomposer remove
ofPHPCSDevTools
.For the time being - until v 1.0.0 has been tagged for the
PHPCSDevTools
package -, therequire
will use thedev-develop
branch ofPHPCSDevTools
.Also, the
composer validate
check doesn't need to be run on every build. Running it on just one build is sufficient, so moving it to thesniff
stage.