-
-
Notifications
You must be signed in to change notification settings - Fork 38
Template for use with pull request on custom code standard projects
To gain more widespread support for PHP_CodeSniffer installers, it is important that maintainers of external PHP_CodeSniffer standards adopt using the "type" : "phpcodesniffer-standard" in their project's composer.json.
Opening an issue (or even better: a pull-request) for such a change is trivial. Finding the right words to explain the rationale can be more daunting.
Below is a template that can be used ad-verbatim to accompany any issue or pull-request to add (or change) the "type" : "phpcodesniffer-standard" in a project's Composer file.
The text below can be selected and copied as-is:
This PR suggests changing the Composer package type to enable automatic standard registration via the [PHPCSStandards Composer installer plugin][composer-installer].
## Problem/Motivation
Composer allows declaring [a package's type][composer-package-type]. When no type is declared, the default is "library".
There is a [Composer plugin][composer-plugin] that can install custom PHP_CodeSniffer standards: https://github.com/PHPCSStandards/composer-installer
This plugin is part of the [PHPCSStandards][php-cs-standards] organisation, which is the new official home of [PHP_CodeSniffer][php-codesniffer].
For this installer to work, the package type needs to be set to `phpcodesniffer-standard`.
A majority of re-usable external standards already [use this type][phpcodesniffer-packages]. As a side benefit, using this type will allow end-users to more easily find other external PHP_CodeSniffer standards that may be interesting to them when searching on Packagist.
## Proposed changes
Adding the following line to `composer.json` will allow the [Composer installer plugin][composer-plugin] to automatically install this coding standard:
```json
"type" : "phpcodesniffer-standard"
```
This will in _no way_ change the existing behavior of this package for users that do not include the Composer plugin mentioned above in their projects' `composer.json`.
[composer-installer]: https://github.com/PHPCSStandards/composer-installer
[composer-package-type]: https://getcomposer.org/doc/04-schema.md#type
[composer-plugin]: https://getcomposer.org/doc/articles/plugins.md
[phpcodesniffer-packages]: https://packagist.org/?type=phpcodesniffer-standard
[php-cs-standards]: https://github.com/PHPCSStandards/
[php-codesniffer]: https://github.com/PHPCSStandards/PHP_CodeSniffer
The template above will render (more or less) like this:
This PR suggests changing the Composer package type to enable automatic standard registration via the PHPCSStandards Composer installer plugin.
Composer allows declaring a package's type. When no type is declared, the default is "library".
There is a Composer plugin that can install custom PHP_CodeSniffer standards: https://github.com/PHPCSStandards/composer-installer
This plugin is part of the PHPCSStandards organisation, which is the new official home of PHP_CodeSniffer.
For this installer to work, the package type needs to be set to phpcodesniffer-standard.
A majority of re-usable external standards already use this type. As a side benefit, using this type will allow end-users to more easily find other external PHP_CodeSniffer standards that may be interesting to them when searching on Packagist.
Adding the following line to composer.json will allow the Composer installer plugin to automatically install this coding standard:
"type" : "phpcodesniffer-standard"This will in no way change the existing behavior of this package for users that do not include the Composer plugin mentioned above in their projects' composer.json.

To the extent possible under law,
Dealerdirect and PHPCSStandards
have waived all copyright and related or neighboring rights to this
"Template for use with pull-request on custom PHP_Codesniffer code-standard projects".