Set of rules for PHP_CodeSniffer preferring tabs and based on Nette coding standard.
Check rules overview for examples.
$ composer require zenify/coding-standard --dev
Run with Php_CodeSniffer:
$ vendor/bin/phpcs src --standard=vendor/zenify/coding-standard/src/ZenifyCodingStandard/ruleset.xml -p
That's all!
If you use PhpStorm, code sniffer can check your syntax as you write. How to integrate?
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?