Skip to content

Template for use with pull request on custom code standard projects

Ben Peachey edited this page Aug 26, 2024 · 4 revisions

Introduction

To gain more widespread support for PHPCodeSniffer installers (not just this project) it is important that maintainers of custom code-standard adapt 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 use ad-verbatim to accompany any issue or pull-request to add (or change) the "type" : "phpcodesniffer-standard" in a project's composer file.

The template

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

## 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 plugins][composer-plugin] that can install custom PHP CodeSniffer standards: https://github.com/PHPCSStandards/PHP_CodeSniffer

This plugin is part of [PHPCSStandards][php-cs-standards], 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`.

There are already [a lot of packages][phpcodesniffer-packages] that adhere to this type.

## Proposed changes

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

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

This will in _no way_ change the existing behavior of this package for users that do not include the package 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
[phpcodesniffer-packages]: https://github.com/search?p=2&q=filename%3Acomposer.json+type+phpcodesniffer+standard&type=Code&utf8=%E2%9C%93
[php-cs-standards]: https://github.com/PHPCSStandards/
[php-codesniffer]: https://github.com/PHPCSStandards/PHP_CodeSniffer

Rendering example

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

Problem/Motivation

Composer allows declaring a package's type. When no type is declared, the default is "library".

There is a composer plugins that can install custom PHP CodeSniffer standards: https://github.com/PHPCSStandards/PHP_CodeSniffer

This plugin is part of PHPCSStandards, which is the new official home of PHP_CodeSniffer

For this installer to work, the package type needs to be set to phpcodesniffer-standard.

There are already a lot of packages that adhere to this type.

Proposed changes

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

    "type" : "phpcodesniffer-standard"

This will in no way change the existing behavior of this package for users that do not include the package 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 PHPCodesniffer code-standard projects".

Clone this wiki locally