Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 2 KB

README.md

File metadata and controls

57 lines (36 loc) · 2 KB

Coding Standard

Build Status Quality Score Code Coverage Downloads Latest stable

Set of rules for PHP_CodeSniffer preferring tabs and based on Nette coding standard.

Check rules overview for examples.

Install

$ composer require zenify/coding-standard --dev

Usage

Run with Php_CodeSniffer:

$ vendor/bin/phpcs src --standard=vendor/zenify/coding-standard/src/ZenifyCodingStandard/ruleset.xml -p

That's all!

PhpStorm Integration

If you use PhpStorm, code sniffer can check your syntax as you write. How to integrate?

How to be both Lazy and Safe

Composer hook

In case you don't want to use Php_CodeSniffer manually for every change in the code you make, you can add pre-commit hook via composer.json:

"scripts": {
	"post-install-cmd": [
		"Zenify\\CodingStandard\\Composer\\ScriptHandler::addPhpCsToPreCommitHook"
	],
	"post-update-cmd": [
		"Zenify\\CodingStandard\\Composer\\ScriptHandler::addPhpCsToPreCommitHook"
	]
}

Every time you try to commit, Php_CodeSniffer will run on changed .php files only.

This is much faster than checking whole project, running manually or wait for CI.

Pretty cool, huh?