I am using php-cs-fixer and decided to try to put the command in pre-commit hook.
#!/bin/sh
echo "php-cs-fixer pre commit hook start"
SRC="src/Controller/Api/FlowsController.php"
exec tools/php-cs-fixer/vendor/bin/php-cs-fixer fix $SRC
echo "php-cs-fixer pre commit hook finish"
So the php-cs-fixer command works fine, but the changes are not commited after it. I also don't see the final echo statement when the hook is done. What I see on committing is:
toma.tomov@MBP-TOMA myproject % git commit -m "test"
php-cs-fixer pre commit hook start
Loaded config default from "/Users/toma.tomov/Desktop/projects/myproject/.php-cs-fixer.dist.php".
Using cache file ".php-cs-fixer.cache".
Paths from configuration file have been overridden by paths provided as command arguments.
1) src/Controller/Api/FlowsController.php
Fixed all files in 2.028 seconds, 26.000 MB memory used
[PHP-CS-FIXER 9550f90a22] test
1 file changed, 2 insertions(+)