2016-05-30 18:19:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
### Tool to check for PHP Syntax errors
|
2018-05-02 12:11:51 +02:00
|
|
|
###
|
2016-05-30 18:19:48 +02:00
|
|
|
### Usage: doc/php_syntax_check [file or directory, defaults to whole egrouware]
|
2018-05-02 12:11:51 +02:00
|
|
|
###
|
2016-07-11 22:39:42 +02:00
|
|
|
### Will output all PHP Fatal, Parse errors and also Deprecated incl. filename
|
2018-05-02 12:11:51 +02:00
|
|
|
###
|
2016-05-30 18:19:48 +02:00
|
|
|
### Exit-status: 0 on no error, but maybe Deprecated warnings, 1 on error
|
2018-05-02 12:11:51 +02:00
|
|
|
###
|
|
|
|
### Use PHP environment variable to point to a certain PHP binary.
|
2016-05-30 18:19:48 +02:00
|
|
|
################################################################################
|
|
|
|
|
2020-06-03 13:12:19 +02:00
|
|
|
find ${@-$(dirname $0)} -name '*.php' -exec ${PHP:-php} -l {} \; 2>&1 | \
|
2016-06-03 08:41:47 +02:00
|
|
|
# only show errors and PHP Deprecated, no success messages
|
2016-05-30 21:07:38 +02:00
|
|
|
egrep '^(PHP|Parse error)' | \
|
2020-06-03 13:12:19 +02:00
|
|
|
# suppress everything in vendor, as they need to be solved by the vendor
|
|
|
|
egrep -v 'vendor/' | \
|
2016-06-03 08:41:47 +02:00
|
|
|
# output everything to stderr
|
|
|
|
tee /dev/fd/2 | \
|
|
|
|
perl -pe 'END { exit $status } $status=1 if /^(PHP Fatal|(PHP )?Parse error)/;' > /dev/null
|