Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bigwing/phpcs-composer

BigWing's PHP Code Sniffer ruleset for WordPress-based projects.
https://github.com/bigwing/phpcs-composer

composer ide lint phpcs phpcs-standard ruleset wordpress wordpress-development

Last synced: 4 days ago
JSON representation

BigWing's PHP Code Sniffer ruleset for WordPress-based projects.

Awesome Lists containing this project

README

        

# BigWing PHPCS Configuration

> Composer library to provide drop in installation and configuration of [WPCS](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) and [PHPCompatibilityWP](https://github.com/PHPCompatibility/PHPCompatibilityWP), setting reasonable defaults for WordPress development with nearly zero configuration.

[![Support Level](https://img.shields.io/badge/support-internal-blue.svg)](#support-level) [![MIT License](https://img.shields.io/github/license/bigwing/phpcs-composer.svg)](https://github.com/bigwing/phpcs-composer/blob/master/LICENSE)

## Installation

Install the library via Composer:

```bash
$ composer require --dev bigwing/phpcs-composer:dev-master
```

That's it!

## Usage

Lint your PHP files with the following command:

```bash
$ ./vendor/bin/phpcs .
```

If relying on Composer, edited the `composer.json` file by adding the following:

```json
"scripts": {
"lint": [
"phpcs . --standard=BigWing-WP"
],
}
```

Then lint via:

```bash
$ composer run lint
```

### Continuous Integration

PHPCS Configuration plays nicely with Continuous Integration solutions. Out of the box, the library loads the `BigWing-WP` ruleset, and checks for syntax errors for PHP 7.2 or higher.

To override the default PHP version check, set the `--runtime-set testVersion 7.2-` configuration option. Example for PHP version 7.4 and above:

```bash
$ ./vendor/bin/phpcs --runtime-set testVersion 7.4-
```

See more [information about specifying PHP version](https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions).

Note that you can only overrule PHP version check from the command-line.

### IDE Integration

Some IDE integrations of PHPCS fail to register the `BigWing-WP` ruleset. In order to rectify this, place `.phpcs.xml.dist` at your project root:

```xml

```

## Support Level

**Internal:** BigWing is working on this for internal projects, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.

## Thanks and Credits

- 10up for their [PHPCS ruleset](https://github.com/10up/phpcs-composer) that this is based on.
- The [WordPress Coding Standards contributors](https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors) for laying the groundwork for
standardized code sniffing in WordPress.