#!/usr/bin/env php = 0) { $lint_exclude = 'vendor'; } else { $lint_exclude = 'vendor|lib/influxdb-php'; } $lint_cmd = 'find . -regextype posix-extended -regex "\./('; $lint_cmd .= $lint_exclude; $lint_cmd .= ')" -prune -o -name "*.php" -print0 | xargs -0 -n1 -P8 php -l '; $lint_cmd .= '| grep -v "^No syntax errors detected"; test $? -eq 1'; exec($lint_cmd, $lint_output, $lint_ret); if ($lint_ret > 0) { print(implode(PHP_EOL, $lint_output) . PHP_EOL); } else { echo "success\n"; } return $lint_ret; } /** * Runs phpcs --standard=PSR2 against the code base * * @param bool $passthru display the output as comes in * @return int the return value from phpcs (0 = success) */ function check_style($passthru = false) { echo 'Checking PSR-2 style...'.($passthru ? "\n" : ' '); $cs_exclude = '--ignore=html/lib/* --ignore=html/plugins/'; $cs_cmd = "./vendor/bin/phpcs -n -p --colors --extensions=php --standard=PSR2 $cs_exclude html"; $cs_output = ''; if ($passthru) { passthru($cs_cmd, $cs_ret); } else { exec($cs_cmd, $cs_output, $cs_ret); } if (!$passthru) { if ($cs_ret > 0) { echo "failed\n"; print(implode(PHP_EOL, $cs_output) . PHP_EOL); } else { echo "success\n"; } } return $cs_ret; } /** * Runs phpunit * * @param bool $passthru display the output as comes in * @return int the return value from phpunit (0 = success) */ function check_unit($passthru = false) { echo 'Running unit tests...'.($passthru ? "\n" : ' '); $phpunit_cmd = './vendor/bin/phpunit --colors=always'; $phpunit_output = ''; if ($passthru) { passthru($phpunit_cmd, $phpunit_ret); } else { exec($phpunit_cmd, $phpunit_output, $phpunit_ret); } if (!$passthru) { if ($phpunit_ret > 0) { echo "failed\n"; print(implode(PHP_EOL, $phpunit_output) . PHP_EOL); } else { echo "success\n"; } } return $phpunit_ret; }