From a06fa611091458e3af3b4b892a4fe725eba1764b Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Mon, 11 Apr 2016 12:37:06 +0200 Subject: [PATCH] Add a script that checks the syntax for all PHP and JSON files. --- bin/check-syntax.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 bin/check-syntax.sh diff --git a/bin/check-syntax.sh b/bin/check-syntax.sh new file mode 100755 index 000000000..0af1a43ce --- /dev/null +++ b/bin/check-syntax.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +PHP='/usr/bin/env php' +RETURN=0 + +# check PHP files +for FILE in `find attributemap bin lib modules www -name "*.php"`; do + $PHP -l $FILE > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Syntax check failed for ${FILE}" + RETURN=`expr ${RETURN} + 1` + fi +done + +# check JSON files +for FILE in `find dictionaries modules -name "*.json"`; do + $PHP -r "exit((json_decode(file_get_contents('$FILE')) === null) ? 1 : 0);" + if [ $? -ne 0 ]; then + echo "Syntax check failed for ${FILE}" + RETURN=`expr ${RETURN} + 1` + fi +done + +exit $RETURN -- GitLab