Adjusted a bit, still not accurate enough and may not reflect inflation
[core.git] / 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" | grep -v "third_party"`
5
6 for SCRIPT in ${PHP};
7 do
8         HEADER=`cat ${SCRIPT} | head -n 1 | grep -v "<?"`
9
10         FOOTER=`cat ${SCRIPT} | tail -n 1 | grep -v "?>"`
11
12         if [ -n "${HEADER}" ];
13         then
14                 echo "$0: Script '${SCRIPT}' has non-typical header."
15         fi
16
17         if [ -n "${FOOTER}" ];
18         then
19                 echo "$0: Script '${SCRIPT}' has non-typical footer."
20         fi
21
22         LINT=`php -l "${SCRIPT}" 2>&1 | grep -v "No syntax errors detected in"`
23
24         if [ -n "${LINT}" ]
25         then
26                 echo "$0: ${LINT}"
27         fi
28 done
29
30 echo "$0: All done."
31 exit 0