From 69c1741597a7be098f08238753f56c32eed00fb9 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Wed, 31 Dec 2014 14:27:10 -0800 Subject: [PATCH 1/2] Prohibit tab characters in php files --- tests/script.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/script.sh b/tests/script.sh index ea53120..d7a4d92 100644 --- a/tests/script.sh +++ b/tests/script.sh @@ -4,7 +4,14 @@ find . -type "f" -iname "*.php" | xargs -L "1" php -l # Run tests. cd tests && phpunit --configuration phpunit.xml -# Check for trailing whitespace in php files. +# Prohibit tab characters in php files. +tab_char=$(find . -type "f" -iname "*.php" -exec grep --line-number -H --perl-regexp "\t" {} \;) +if [[ ! -z "${tab_char}" ]]; then + echo -e "${tab_char}" | perl -pe 's/^(.*)$/Tab character found in \1/' + exit 1 +fi + +# Prohibit trailing whitespace in php files. trailing_whitespace=$(find . -type "f" -iname "*.php" -exec egrep --line-number -H " +$" {} \;) if [[ ! -z "${trailing_whitespace}" ]]; then echo -e "${trailing_whitespace}" | perl -pe 's/^(.*)$/Trailing whitespace found in \1/' From c1cf3b3f08470a5666dc3ff17cb65cf17359b802 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Thu, 1 Jan 2015 16:19:12 -0800 Subject: [PATCH 2/2] Enforce line ending consistency in php files --- tests/script.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/script.sh b/tests/script.sh index d7a4d92..6600269 100644 --- a/tests/script.sh +++ b/tests/script.sh @@ -4,7 +4,14 @@ find . -type "f" -iname "*.php" | xargs -L "1" php -l # Run tests. cd tests && phpunit --configuration phpunit.xml -# Prohibit tab characters in php files. +# Enforce line ending consistency in php files. +crlf_file=$(find . -type "f" -iname "*.php" -exec grep --files-with-matches $'\r' {} \;) +if [[ ! -z "${crlf_file}" ]]; then + echo "${crlf_file}" | perl -pe 's/(.*)/CRLF line terminators found in \1/' + exit 1 +fi + +# Enforce indentation character consistency in php files. tab_char=$(find . -type "f" -iname "*.php" -exec grep --line-number -H --perl-regexp "\t" {} \;) if [[ ! -z "${tab_char}" ]]; then echo -e "${tab_char}" | perl -pe 's/^(.*)$/Tab character found in \1/'