]> git.mxchange.org Git - core.git/blob - contrib/find-bad-php.sh
Continued:
[core.git] / contrib / find-bad-php.sh
1 #!/bin/sh
2
3 echo "$0: Searching for PHP scripts (except 3rd party) ..."
4 PHP=$(find -type f -name "*.php" 2>&1 | grep -v "third_party" | grep -v "/vendor/" | grep -v "smarty3/compiled/")
5
6 for SCRIPT in ${PHP};
7 do
8         SHORT_OPEN_TAG=$(cat ${SCRIPT} | head -n 1 | grep -v "<?")
9         CLOSING_TAG=$(cat ${SCRIPT} | tail -n 1 | grep "?>")
10
11         if [ -n "${SHORT_OPEN_TAG}" ];
12         then
13                 echo "$0: Script '${SCRIPT}' has short opening tag (<?)."
14         fi
15
16         if [ -n "${CLOSING_TAG}" ];
17         then
18                 echo "$0: Script '${SCRIPT}' has discouraged closing tag (?>)."
19         fi
20
21         LINT=$(php -l "${SCRIPT}" 2>&1 | grep -v "Constant FUSE_EDEADLK already defined in Unknown on line 0" | grep -v "No syntax errors detected in")
22
23         if [ -n "${LINT}" ]
24         then
25                 echo "$0: ${LINT}"
26         fi
27 done
28
29 echo "$0: All done."
30 exit 0