diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2020-05-16 07:32:35 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2020-05-16 07:35:19 +0300 |
commit | 8dd310fb6a49171a3c7c85594331773681a17cc1 (patch) | |
tree | 625bbb55a9d46fe39f0b70507da299eb7cabe5b5 /test/bootstrap-dist.php | |
parent | 2866ee7bd1250ffe24864b87fbd8fb55d6ff69d9 (diff) |
Remove assignments in if conditions
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test/bootstrap-dist.php')
-rw-r--r-- | test/bootstrap-dist.php | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php index f2bf432ba8..84ec3e99b1 100644 --- a/test/bootstrap-dist.php +++ b/test/bootstrap-dist.php @@ -91,24 +91,22 @@ $languageEn->activate(); /* Load Database interface */ $GLOBALS['dbi'] = DatabaseInterface::load(new DbiDummy()); -// Set proxy information from env, if available -$http_proxy = getenv('http_proxy'); -if (PHP_SAPI == 'cli' && $http_proxy && ($url_info = parse_url($http_proxy))) { - /** @var string[] */ - $url_info = $url_info; - // phpcs:disable PSR1.Files.SideEffects - define('PROXY_URL', $url_info['host'] . ':' . $url_info['port']); - define('PROXY_USER', empty($url_info['user']) ? '' : $url_info['user']); - define('PROXY_PASS', empty($url_info['pass']) ? '' : $url_info['pass']); - // phpcs:enable -} else { - // phpcs:disable PSR1.Files.SideEffects - define('PROXY_URL', ''); - define('PROXY_USER', ''); - define('PROXY_PASS', ''); - // phpcs:enable +$httpProxy = getenv('http_proxy'); +$urlInfo = parse_url((string) $httpProxy); + +if (PHP_SAPI == 'cli' && is_array($urlInfo)) { + $proxyUrl = ($urlInfo['host'] ?? '') + . (isset($urlInfo['port']) ? ':' . $urlInfo['port'] : ''); + $proxyUser = $urlInfo['user'] ?? ''; + $proxyPass = $urlInfo['pass'] ?? ''; } +// phpcs:disable PSR1.Files.SideEffects +define('PROXY_URL', $proxyUrl ?? ''); +define('PROXY_USER', $proxyUser ?? ''); +define('PROXY_PASS', $proxyPass ?? ''); +// phpcs:enable + // Ensure we have session started session_start(); |