2016-05-30 18:19:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
### Tool to check for PHP Syntax errors
|
|
|
|
### Usage: doc/php_syntax_check [file or directory, defaults to whole egrouware]
|
2016-07-11 22:39:42 +02:00
|
|
|
### Will output all PHP Fatal, Parse errors and also Deprecated incl. filename
|
2016-05-30 18:19:48 +02:00
|
|
|
### Exit-status: 0 on no error, but maybe Deprecated warnings, 1 on error
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
cd `dirname $0`
|
|
|
|
cd ..
|
|
|
|
|
2016-08-07 17:22:22 +02:00
|
|
|
find ${@-.} -name '*.php' -exec 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)' | \
|
2016-07-10 11:49:47 +02:00
|
|
|
# suppress PHP Deprecated in vendor, as they need to be solved by the vendor
|
|
|
|
egrep -v '^PHP Deprecated.*/vendor/' | \
|
2016-06-03 08:41:47 +02:00
|
|
|
# output everything to stderr
|
|
|
|
tee /dev/fd/2 | \
|
|
|
|
# exclude several known problems, to be able to find new ones
|
|
|
|
# exclude old / not used PEAR Autoloader giving PHP Fatal error: Method PEAR_Autoloader::__call() must take exactly 2 arguments
|
|
|
|
grep -v 'vendor/pear-pear.php.net/PEAR/PEAR/Autoloader.php' | \
|
|
|
|
# exclude composer conditional included autoload_static.php, as it requires PHP 5.6+
|
|
|
|
grep -v 'vendor/composer/autoload_static.php' | \
|
2016-07-11 22:39:42 +02:00
|
|
|
# exclude vendor/phpunit it shows many PHP Parse errors in PHP < 7.0
|
|
|
|
grep -v 'vendor/phpunit' | \
|
2016-12-08 16:01:55 +01:00
|
|
|
# suppress PHP Parse errors in PHP < 7.0 in dependency of phpunit: phpspec/prophecy
|
|
|
|
grep -v 'vendor/phpspec/prophecy' | \
|
2016-06-03 08:41:47 +02:00
|
|
|
# phpFreeChat does not work with PHP7
|
|
|
|
grep -v 'phpfreechat/phpfreechat/' | \
|
2017-08-18 10:34:51 +02:00
|
|
|
# not used part of ADOdb give PHP Fatal error: Cannot unset $this
|
|
|
|
grep -v 'adodb-xmlschema' | \
|
2016-06-03 08:41:47 +02:00
|
|
|
perl -pe 'END { exit $status } $status=1 if /^(PHP Fatal|(PHP )?Parse error)/;' > /dev/null
|