[PhpUnitBridge] Replace global function by closure

This commit is contained in:
Nicolas Grekas 2018-04-05 12:56:53 +02:00
parent f738013ec9
commit 65b601323f

View File

@ -15,7 +15,7 @@
error_reporting(-1); error_reporting(-1);
function getEnvVar($name, $default = false) { $getEnvVar = function ($name, $default = false) {
if (false !== $value = getenv($name)) { if (false !== $value = getenv($name)) {
return $value; return $value;
} }
@ -42,14 +42,14 @@ function getEnvVar($name, $default = false) {
} }
return $default; return $default;
} };
if (PHP_VERSION_ID >= 70200) { if (PHP_VERSION_ID >= 70200) {
// PHPUnit 6 is required for PHP 7.2+ // PHPUnit 6 is required for PHP 7.2+
$PHPUNIT_VERSION = getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5'); $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
} elseif (PHP_VERSION_ID >= 50600) { } elseif (PHP_VERSION_ID >= 50600) {
// PHPUnit 4 does not support PHP 7 // PHPUnit 4 does not support PHP 7
$PHPUNIT_VERSION = getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7'); $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
} else { } else {
// PHPUnit 5.1 requires PHP 5.6+ // PHPUnit 5.1 requires PHP 5.6+
$PHPUNIT_VERSION = '4.8'; $PHPUNIT_VERSION = '4.8';
@ -69,7 +69,7 @@ while (!file_exists($root.'/'.$COMPOSER_JSON) || file_exists($root.'/Deprecation
} }
$oldPwd = getcwd(); $oldPwd = getcwd();
$PHPUNIT_DIR = getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit'); $PHPUNIT_DIR = $getEnvVar('SYMFONY_PHPUNIT_DIR', $root.'/vendor/bin/.phpunit');
$PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php'; $PHP = defined('PHP_BINARY') ? PHP_BINARY : 'php';
$PHP = escapeshellarg($PHP); $PHP = escapeshellarg($PHP);
if ('phpdbg' === PHP_SAPI) { if ('phpdbg' === PHP_SAPI) {
@ -81,7 +81,7 @@ $COMPOSER = file_exists($COMPOSER = $oldPwd.'/composer.phar') || ($COMPOSER = rt
: 'composer'; : 'composer';
$SYMFONY_PHPUNIT_REMOVE = getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy symfony/yaml'); $SYMFONY_PHPUNIT_REMOVE = $getEnvVar('SYMFONY_PHPUNIT_REMOVE', 'phpspec/prophecy symfony/yaml');
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__)."\n".$SYMFONY_PHPUNIT_REMOVE !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) { if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__FILE__)."\n".$SYMFONY_PHPUNIT_REMOVE !== @file_get_contents("$PHPUNIT_DIR/.$PHPUNIT_VERSION.md5")) {
// Build a standalone phpunit without symfony/yaml nor prophecy by default // Build a standalone phpunit without symfony/yaml nor prophecy by default