Skip to content

Instantly share code, notes, and snippets.

@rkaldung
Last active December 14, 2015 08:39
Show Gist options
  • Save rkaldung/5059554 to your computer and use it in GitHub Desktop.
Save rkaldung/5059554 to your computer and use it in GitHub Desktop.
git pre-commit hook with php lint and code style fix
#!/bin/sh
#
# adjust php-cs-fixer configuration if needed, see http://cs.sensiolabs.org/
# Redirect output to stderr.
exec 1>&2
for f in $(git diff --cached --name-only --diff-filter=AMC | grep -e '\.php$')
do
php -l "${f}" || exit 1
php-cs-fixer fix "${f}" --fixers=php_closing_tag
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment