Skip to content

Template for use with pull request on custom code sniff projects

Ben Peachey edited this page Apr 11, 2017 · 5 revisions

Introduction

To gain more widespread support for PHPCodeSniffer installers (not just this project) it is important that maintainers of custom codesniffs adapt using the "type" : "phpcodesniffer-standard" in their project's composer.json.

Opening a pull-request for such a change is trivial. Finding the right words to explain the rationale behind a PR can be more daunting.

Below is a template that can be use ad-verbatim to accompany any PR that add "type" : "phpcodesniffer-standard" to a projects composer file.

The template

The text below can be selected and copied as-is:

## Problem/Motivation

Composer allows declaring [the type of a package][composer-package-type]. If no 
type is declared, the defaults is "library".

There are various [composer plugins][composer-plugin] that can install custom
PHP CodeSniffer standards:

- https://github.com/higidi/composer-phpcodesniffer-standards-plugin
- https://github.com/DealerDirect/phpcodesniffer-composer-installer
- https://github.com/SimplyAdmire/ComposerPlugins

For these installers to work, the package type needs to be set to "phpcodesniffer-standard".

## Proposed changes

Adding the following line to the `composer.json` will make it possible for such packages to install this custom sniff using composer:

```json
    "type" : "phpcodesniffer-standard"
```

This will in _no way_ change the existing behaviour of this package for user that do not include one of the packages mentioned above in their projects `composer.json`.

[composer-package-type]: https://getcomposer.org/doc/04-schema.md#type
[composer-plugin]: https://getcomposer.org/doc/articles/plugins.md

Rendering example

The template above will render (more or less) like this:

Problem/Motivation

Composer allows declaring the type of a package. If no type is declared, the defaults is "library".

There are various composer plugins that can install custom PHP CodeSniffer standards:

For these installers to work, the package type needs to be set to "phpcodesniffer-standard".

Proposed changes

Adding the following line to the composer.json will make it possible for such packages to install this custom sniff using composer:

    "type" : "phpcodesniffer-standard"

This will in no way change the existing behaviour of this package for user that do not include one of the packages mentioned above in their projects composer.json.

Copyright of this template

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