Download the PHP package phpcsstandards/phpcsdevtools without Composer
On this page you can find all versions of the php package phpcsstandards/phpcsdevtools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpcsstandards/phpcsdevtools
More information about phpcsstandards/phpcsdevtools
Files in phpcsstandards/phpcsdevtools
Package phpcsdevtools
Short Description Tools for PHP_CodeSniffer sniff developers.
License LGPL-3.0-or-later
Homepage https://phpcsstandards.github.io/PHPCSDevTools/
Informations about the package phpcsdevtools
PHPCSDevTools for developers of PHP_CodeSniffer sniffs
This is a set of tools to assist developers of sniffs for PHP CodeSniffer.
- Installation
- Composer Project-based Installation
- Composer Global Installation
- Stand-alone Installation
- Features
- Checking whether all sniffs in a PHPCS standard are feature complete
- Sniff Debugging
- Documentation XSD Validation
- Contributing
- License
Installation
Composer Project-based Installation
Run the following from the root of your project:
Composer Global Installation
If you work on several different sniff repos, you may want to install this toolset globally:
Composer will automatically install dependencies and register the PHPCSDebug standard with PHP_CodeSniffer using the Composer PHPCS plugin.
Stand-alone Installation
- Install PHP CodeSniffer via your preferred method.
- Register the path to PHPCS in your system
$PATH
environment variable to make thephpcs
command available from anywhere in your file system. - Download the latest PHPCSDevTools release and unzip/untar it into an arbitrary directory. You can also choose to clone this repository using git.
-
Add the path to the directory in which you placed your copy of the PHPCSDevTools repo to the PHP CodeSniffer configuration using the below command:
:warning: Warning: The
installed_paths
command overwrites any previously setinstalled_paths
. If you have previously setinstalled_paths
for other external standards, runphpcs --config-show
first and then run theinstalled_paths
command with all the paths you need separated by commas, i.e.:
Features
Checking whether all sniffs in a PHPCS standard are feature complete
You can now check whether each and every sniff in your standard is accompanied by a documentation XML file (warning) as well as unit test files (error). The tool will also verify that there are no documentation or test files in your standard which are not associated with a sniff ("orphaned" files).
To use the tool, run it from the root of your standards repo like so:
If all is good, you will see the following messages:
If there are files missing, you will see errors/warnings for each missing file, like so:
If orphaned files are found you will receive a warning for each orphaned file found, like so:
For the fastest results, it is recommended to pass the name of the subdirectory where your standard is located to the script, like so:
Options
Sniff Debugging
Once this project is installed, you will see a new PHPCSDebug
ruleset in the list of installed standards when you run phpcs -i
.
For now, this standard only contains one sniff: PHPCSDebug.Debug.TokenList
.
This sniff will display compact, but detailed information about the tokens found in a (test case) file.
This sniff is compatible with PHPCS 3.1.0+.
Typical usage:
- Set up a test case file for a new sniff you intend to write.
-
Run PHPCS over the test case file using this standard to see a list of the tokens found in the file:
- Or use it together with the new sniff you are developing:
The output will look something along the lines of:
PHPCS itself can also display similar information using the -vv
or -vvv
verbosity flags, however, when using those, you will receive a lot more information than just the token list and, while useful for debugging PHPCS itself, the additional information is mostly just noise when developing a sniff.
Documentation XSD Validation
This project contains an XML Schema Definition (XSD) to allow for validation PHPCS documentation XML files. Following the XSD will make sure your documentation can be correctly displayed when using the PHPCS --generator
option.
In order to use it, you'll need to add the schema related attributes to the documentation
element of the sniff documentation file, like so:
If your IDE or editor supports automatic validation of XML files, you will be notified if your documentation XML file has the correct number of elements, correct type and number of certain attributes, and title length among other things.
Validating your docs against the XSD
You can validate your PHPCS XML documentation against the XSD file using xmllint. This validation can be run locally if you have xmllint installed, as well as in CI (continuous integration).
An example of a workflow job for GitHub Actions CI looks like this:
:point_right: You'll need to replace the YourRuleset
within the command with the name of your ruleset (of course).
Contributing
Contributions to this project are welcome. Clone this repository, branch off from develop
, make your changes, commit them and send in a pull request.
If unsure whether the changes you are proposing would be welcome, open an issue first to discuss your proposal.
License
This code is released under the GNU Lesser General Public License (LGPLv3).
All versions of phpcsdevtools with dependencies
squizlabs/php_codesniffer Version ^3.1.0
dealerdirect/phpcodesniffer-composer-installer Version ^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0