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.
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
You have 2 options how to use NCS in your project.
Nette packages require this approach, because NCS depends on many Nette packages. NCS should be installed to standalone directory, so changing the Nette code by NCS doesn't break NCS.
The easiest way is to setup
install: - composer create-project nette/coding-standard temp/nette-coding-standard script: - temp/nette-coding-standard/ecs check src tests --config temp/nette-coding-standard/coding-standard-php71.neon
And you are ready to go!
I prefer this in projects, where I want to check coding standards locally and have dependencies up-to date. It's easier than composer project, where you need to remember to update dependencies manually in the directory.
composer require nette/coding-standard --dev
Check the code:
vendor/bin/ecs check src tests --config vendor/nette/coding-standard/coding-standard-php71.neon
Fix the code:
vendor/bin/ecs check src tests --config vendor/nette/coding-standard/coding-standard-php71.neon --fix
Do you need to check code that is not PHP 7.0 ready? You can.
At the moment there are 3 configs with set of checkers (click to see their content):
Config with higher PHP version includes all lower versions, so with
coding-standard-php71.neon you cover the other 2 configs as well.
For PHP 5.6 it would like this:
vendor/bin/ecs check src tests --config vendor/nette/coding-standard/coding-standard-php56.neon