Skip to content

Instantly share code, notes, and snippets.

@markkelnar
Created August 6, 2014 01:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markkelnar/ebc2f147ce70116991b2 to your computer and use it in GitHub Desktop.
Save markkelnar/ebc2f147ce70116991b2 to your computer and use it in GitHub Desktop.
PHP lint checker - pre commit hook
#!/bin/bash
# Put this file in .git/hooks/pre-commit
# Change it to be executable! If you don't do this, it won't work
# chmod +x .git/hooks/pre-commit
git diff-index --diff-filter=ACMR --name-only --cached HEAD |
grep '.php$' |
xargs -tn1 php -l
if (( $? )); then
echo Upon commit, PHP lint check failed, you fool!
exit 1
fi
#GREEN MEANS GO
echo -e PASSED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment