I try to use CodeSniffer in combination with a pre-commit git hook. I can run phpcs --standard=PSR2 PhpFile.php
so the installation of CodeSniffer seems to work fine.
I try to use this piece of code as premade git hook. However I'm pretty sure this code is not compatible with Windows and I don't know how much effort it takes to port it. So maybe it is better to write my own code for parsing the staged (PHP) files with CodeSniffer. I just could use some help how to do this.
Tried
Well I knew I had to start with getting the staged files like this:
git diff --cached --name-only
But I cannot use grep
to only get the .php files. So I think we need an equivalent in Windows?