An open API service indexing awesome lists of open source software.

https://github.com/chi-teck/drupal-coder-extension

A highly opinionated extension for Drupal coding standards.
https://github.com/chi-teck/drupal-coder-extension

Last synced: 8 months ago
JSON representation

A highly opinionated extension for Drupal coding standards.

Awesome Lists containing this project

README

          

# Extended Drupal Coding Standard

This project offers a set of preconfigured rules for PHP Code Sniffer mainly related to new PHP features that are not
covered by Drupal coding standards yet.

## System Requirements

PHP 8.1+

## Installation

Install the standard locally through Composer.

```shell
composer require --dev chi-teck/drupal-coder-extension
```

Add `DrupalExtended` standard to your project's `phpcs.xml`.

```xml







./src/Exception

```

A complete example of `phpcs.xml`:

```xml

PHP Code Sniffer configuration for My Project.




./web/modules/custom
./web/themes/custom
./tests


./docroot/themes/custom/example/node_modules

```

## Usage

Run the `phpcs` script to check custom code.

```
./vendor/bin/phpcs -ps --standard=phpcs.xml
```

Run the `phpcbf` script to automatically correct coding standard violations.

```
./vendor/bin/phpcbf
```

You also can put this command into projects `composer.json`:

```json
{

"scripts": {
"phpcs": "vendor/bin/phpcs -ps"
}
}
```

Then you can use it like

```shell
composer phpcs
```

## Links

* [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer)
* [Drupal Coding Standards](https://www.drupal.org/node/2802991)
* [Drupal Coder](https://www.drupal.org/project/coder)
* [Slevomat Coding Standard](https://github.com/slevomat/coding-standard)

## License

GNU General Public License, version 2 or later.