Continued:
[core.git] / contrib / find-bad-php.sh
index 0144c2c4c889dd2c8f7b223ed4be4a8a8c858b20..45d6e7afd6e21594da63dd18b17c75d75e4446e5 100755 (executable)
@@ -1,22 +1,21 @@
 #!/bin/sh
 
 echo "$0: Searching for PHP scripts (except 3rd party) ..."
-PHP=$(find -type f -name "*.php" 2>&1 | grep -v "third_party" | grep -v "smarty3/compiled/")
+PHP=$(find -type f -name "*.php" 2>&1 | grep -v "third_party" | grep -v "/vendor/" | grep -v "smarty3/compiled/")
 
 for SCRIPT in ${PHP};
 do
-       HEADER=$(cat ${SCRIPT} | head -n 1 | grep -v "<?")
+       SHORT_OPEN_TAG=$(cat ${SCRIPT} | head -n 1 | grep -v "<?")
+       CLOSING_TAG=$(cat ${SCRIPT} | tail -n 1 | grep "?>")
 
-       FOOTER=$(cat ${SCRIPT} | tail -n 1 | grep "?>")
-
-       if [ -n "${HEADER}" ];
+       if [ -n "${SHORT_OPEN_TAG}" ];
        then
-               echo "$0: Script '${SCRIPT}' has non-typical header."
+               echo "$0: Script '${SCRIPT}' has short opening tag (<?)."
        fi
 
-       if [ -n "${FOOTER}" ];
+       if [ -n "${CLOSING_TAG}" ];
        then
-               echo "$0: Script '${SCRIPT}' has discouraged footer."
+               echo "$0: Script '${SCRIPT}' has discouraged closing tag (?>)."
        fi
 
        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")