File: check-syntax.sh

package info (click to toggle)
simplesamlphp 1.16.3-1%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 21,036 kB
  • sloc: php: 73,175; ansic: 875; sh: 83; perl: 82; xml: 52; makefile: 46
file content (24 lines) | stat: -rwxr-xr-x 638 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash

PHP='/usr/bin/env php'
RETURN=0

# check PHP files
for FILE in `find attributemap bin config-templates lib metadata-templates modules templates www -name "*.php"`; do
    $PHP -l $FILE > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo "Syntax check failed for ${FILE}"
        RETURN=`expr ${RETURN} + 1`
    fi
done

# check JSON files
for FILE in `find dictionaries modules -name "*.json"`; do
    $PHP -r "exit((json_decode(file_get_contents('$FILE')) === null) ? 1 : 0);"
    if [ $? -ne 0 ]; then
        echo "Syntax check failed for ${FILE}"
        RETURN=`expr ${RETURN} + 1`
    fi
done

exit $RETURN