Skip to content

Instantly share code, notes, and snippets.

@spelcaster
Created May 1, 2019 11:22
Show Gist options
  • Save spelcaster/6c6ce2757bfefa7eb337c040e901649f to your computer and use it in GitHub Desktop.
Save spelcaster/6c6ce2757bfefa7eb337c040e901649f to your computer and use it in GitHub Desktop.
Git Hooks for PHP projects
#!/bin/bash
retval=0
while read -r filepath; do
vendor/bin/phplint "$filepath"
retval=$(( $retval + $? ))
done < <(git diff --cached --name-status | awk '$1 != "D" { print $2 }' | grep ".php")
if [[ $retval -gt 0 ]]; then
echo "PHP Syntax error found"
exit 1
fi
@spelcaster
Copy link
Author

You must install overtrue/phplint in your project to use this hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment