Skip to content

Instantly share code, notes, and snippets.

@josue
Created August 25, 2010 21:19
Show Gist options
  • Save josue/550317 to your computer and use it in GitHub Desktop.
Save josue/550317 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author: Josue Rodriguez (@JosueR)
# Grabs the current pwd via Git repo then performs a php syntax on all php files.
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
Git_Root=$(readlink -f ./$(git rev-parse --show-cdup))
option=$1
files_found=0
counter=0
split_at=100
echo
echo "To show each file output, run: $me --show"
echo
echo "Checking all *.php files for correct syntax ..."
echo
echo "Dir: $Git_Root"
echo
for FILE in $(find $Git_Root -name "*.php")
do
if [ "$option" = "--show" ]; then
php -l $FILE
else
echo -n "."
php -l $FILE | grep -i "PHP Parse error"
fi
files_found=$((($files_found)+1))
[ $counter -eq $split_at ] && echo && counter=0 || counter=$((($counter)+1))
done
echo
echo
echo "Done checking php syntax for $files_found files."
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment