How to Apply Nette Coding Standard in Your Project
Updated to Nette CodingStandard 2.0 and EasyCodingStandard 5.
Pull-requests are more fun thanks to automated coding standard. You don't have explain where to put space or bracket. You can talk about architecture or meaning of the code instead. Moreover in open-source. I wanted to make this possible in Nette, but Coding Standards could be found only in documentation.
This year I started to work on a Nette Coding Standard (NCS) that you can put to CLI. And you'll be able set it up in in your project yourself today.
Nette\CodingStandard 2.0 was released 2 months. This version is ready to use, includes all important checkers and is used on all
Nette\* packages in Travis.
NCS checks every pull-request you make to Nette:
All that need is to define stage in
That's it! Just 2 commands and it checks any project you have.
This packages requires PHP 7.1 to run as the rest of the Nette (mostly current
Setup Your Project
Install the package to your dev dependencies:
composer require nette/coding-standard --dev
Good! Now just pick the prepared set.
At the moment there are 3 configs with set of checkers:
Just pick the one that suits you:
vendor/bin/ecs check src tests --config vendor/nette/coding-standard/coding-standard-php71.yml
Then, fix the code:
vendor/bin/ecs check src tests --config vendor/nette/coding-standard/coding-standard-php71.yml --fix
Config with higher PHP version includes all lower versions, so with
coding-standard-php71.yml you cover the other 2 configs as well.