10up/phpcs-composer

Installs: 10 051

Dependents: 11

Suggesters: 0

Stars: 11

Watchers: 65

Forks: 2

Open Issues: 5

Type:phpcodesniffer-standard

dev-master 2019-03-04 14:40 UTC

README

Composer library to provide drop in installation and configuration of WPCS and PHPCompatibilityWP, setting reasonable defaults for WordPress development with nearly zero configuration.

68747470733a2f2f31307570646f74636f6d2d7770656e67696e652e73332e616d617a6f6e6177732e636f6d2f75706c6f6164732f323031362f31302f313075702d4769746875622d42616e6e65722e706e67

Installation

Install the library via Composer:

$ composer require --dev 10up/phpcs-composer:dev-master

That's it!

Usage

Lint your PHP files with the following command:

$ ./vendor/bin/phpcs .

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

	"scripts": {
		"lint": [
			"phpcs ."
		],
	}

Then lint via:

$ composer run lint

Continuous Integration

PHPCS Configuration plays nicely with Continuous Integration solutions. Out of the box, the library loads the 10up-Default ruleset, and checks for syntax errors for PHP 7 or higher.

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

$ ./vendor/bin/phpcs --runtime-set testVersion 7.2-

See more information about specifying PHP version.

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

IDE Integration

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

<?xml version="1.0"?>
<ruleset name="Project Rules">
	<rule ref="10up-Default" />
</ruleset>