|
1 | 1 | # Check syntax in php files.
|
2 | 2 | find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec php -l {} \;
|
3 | 3 |
|
| 4 | +errors=0 |
| 5 | + |
4 | 6 | # Run tests.
|
5 | 7 | phpunit --configuration tests/phpunit.xml
|
6 | 8 | if [[ "${?}" -ne 0 ]]; then
|
7 |
| - exit 1 |
| 9 | + ((errors++)) |
8 | 10 | fi
|
9 | 11 |
|
10 | 12 | # Enforce line ending consistency in php files.
|
11 | 13 | crlf_file=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --files-with-matches $'\r' {} \;)
|
12 | 14 | if [[ ! -z "${crlf_file}" ]]; then
|
13 | 15 | echo "${crlf_file}" | perl -pe 's/(.*)/CRLF line terminators found in \1/'
|
14 |
| - exit 1 |
| 16 | + ((errors++)) |
15 | 17 | fi
|
16 | 18 |
|
17 | 19 | # Enforce indentation character consistency in php files.
|
18 | 20 | tab_char=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec grep --line-number -H --perl-regexp "\t" {} \;)
|
19 | 21 | if [[ ! -z "${tab_char}" ]]; then
|
20 | 22 | echo -e "${tab_char}" | perl -pe 's/^(.*)$/Tab character found in \1/'
|
21 |
| - exit 1 |
| 23 | + ((errors++)) |
22 | 24 | fi
|
23 | 25 |
|
24 | 26 | # Enforce indentation consistency in php files.
|
@@ -53,41 +55,47 @@ if [[ "${TRAVIS_PHP_VERSION}" != "hhvm" ]]; then
|
53 | 55 | invalid_indentation=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec bash -c 'find_invalid_indentation "{}"' \;)
|
54 | 56 | if [[ ! -z "${invalid_indentation}" ]]; then
|
55 | 57 | echo "${invalid_indentation}"
|
56 |
| - exit 1 |
| 58 | + ((errors++)) |
57 | 59 | fi
|
58 | 60 | fi
|
59 | 61 |
|
60 | 62 | # Prohibit trailing whitespace in php files.
|
61 | 63 | trailing_whitespace=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H " +$" {} \;)
|
62 | 64 | if [[ ! -z "${trailing_whitespace}" ]]; then
|
63 | 65 | echo -e "${trailing_whitespace}" | perl -pe 's/^(.*)$/Trailing whitespace found in \1/'
|
64 |
| - exit 1 |
| 66 | + ((errors++)) |
65 | 67 | fi
|
66 | 68 |
|
67 | 69 | # Prohibit long lines in php files.
|
68 | 70 | long_lines=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec awk '{print FILENAME":"NR" "length}' {} \; | awk '$2 > 120')
|
69 | 71 | if [[ ! -z "${long_lines}" ]]; then
|
70 | 72 | echo -e "${long_lines}" | perl -pe 's/^(.*)$/Long lines found in \1/'
|
71 |
| - exit 1 |
| 73 | + ((errors++)) |
72 | 74 | fi
|
73 | 75 |
|
74 | 76 | # Prohibit @author in php files.
|
75 | 77 | at_author=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --line-number -H "@author" {} \;)
|
76 | 78 | if [[ ! -z "${at_author}" ]]; then
|
77 | 79 | echo -e "${at_author}" | perl -pe 's/^(.*)$/\@author found in \1/'
|
78 |
| - exit 1 |
| 80 | + ((errors++)) |
79 | 81 | fi
|
80 | 82 |
|
81 | 83 | # Prohibit screaming caps notation in php files.
|
82 | 84 | caps=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --color=always --line-number -H -e "FALSE[^']" -e "NULL" -e "TRUE" {} \;)
|
83 | 85 | if [[ ! -z "${caps}" ]]; then
|
84 | 86 | echo -e "${caps}" | perl -pe 's/^(.*)$/All caps found in \1/'
|
85 |
| - exit 1 |
| 87 | + ((errors++)) |
86 | 88 | fi
|
87 | 89 |
|
88 | 90 | # Require identical comparison operators (===, not ==) in php files.
|
89 | 91 | equal=$(find . -type "f" -iname "*.php" ! -path "*/vendor/*" -exec egrep --color=always --line-number -H "[^!=]==[^=]" {} \;)
|
90 | 92 | if [[ ! -z "${equal}" ]]; then
|
91 | 93 | echo -e "${equal}" | perl -pe 's/^(.*)$/Non-identical comparison operator found in \1/'
|
| 94 | + ((errors++)) |
| 95 | +fi |
| 96 | + |
| 97 | +if [ $errors -eq 0 ]; then |
| 98 | + exit 0 |
| 99 | +else |
92 | 100 | exit 1
|
93 | 101 | fi
|
0 commit comments