Skip to content

Instantly share code, notes, and snippets.

@bells17
Created June 30, 2014 04:23
Show Gist options
  • Save bells17/541a14294cfef67b891c to your computer and use it in GitHub Desktop.
Save bells17/541a14294cfef67b891c to your computer and use it in GitHub Desktop.
phpのシンタックスチェック ref: http://qiita.com/bells17/items/d771c375c78747b336c7
#!/bin/sh
# $1 phpの文法チェックをしたいディレクトリ
#http://kaworu.jpn.org/kaworu/2007-11-17-2.php
flg=0
phpsyntaxcheck()
{
for i in `find -E "$1" -regex '.*\.(php|inc)' `
do
msg=`php -l "$i"`
check=`echo $msg | cut -c 1-25 `
if [ "$check" != 'No syntax errors detected' ] ; then
echo $msg
echo ''
flg=1
fi
done
}
echo ''
for i in "$@"
do
phpsyntaxcheck "$i"
done
if [ $flg -eq 1 ] ; then
echo 'Syntax check error!'
else
echo 'Syntax check OK!'
fi
echo ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment