Skip to content

Instantly share code, notes, and snippets.

@dmgig
Forked from mathiasverraes/phplint.sh
Last active April 4, 2016 16:03
Show Gist options
  • Save dmgig/758e1f7cbbfbdde6e36db9b4623318fe to your computer and use it in GitHub Desktop.
Save dmgig/758e1f7cbbfbdde6e36db9b4623318fe to your computer and use it in GitHub Desktop.
Recursive PHP Lint script (git tracked files only)
#!/bin/bash
# php linter of git tracked files
# passing --success argument will print no-error files in the list,
# otherwise, only files with parse errors will be displayed.
IFS=$'\n' #split filenames at newlines only
for file in `git ls-tree -r master --name-only`
do
EXTENSION="${file##*.}"
if [ "$EXTENSION" == "php" ] || [ "$EXTENSION" == "phtml" ]
then
RESULTS=`php -l $file`
if [ "$RESULTS" == "No syntax errors detected in $file" ]
then
if [ -n "$1" ]
then
printf '\e[32m%s\e[0m\n' "${RESULTS}"
fi
else
printf '\e[31m%s\e[0m\n' "${RESULTS}"
fi
fi
done
@dmgig
Copy link
Author

dmgig commented Apr 4, 2016

lint git tracked files only, add some color for success and failure.

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