Skip to content

Instantly share code, notes, and snippets.

@johnblackmore
Created March 3, 2015 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnblackmore/75922efe40b0c328f6c2 to your computer and use it in GitHub Desktop.
Save johnblackmore/75922efe40b0c328f6c2 to your computer and use it in GitHub Desktop.
PHP linting pre-commit hook (save to .git/hooks/pre-commit)
#!/bin/bash
git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do
if [[ "$FILE" =~ ^.+(php|inc)$ ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo "Abort! Files failed syntax check" >&2
exit 1
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment