PHP version checks tweaking

main
Possum 9 years ago
parent 13a3349603
commit 29ca21f30e

@ -112,7 +112,7 @@ class ClassMapGenerator
*/ */
private static function findClasses($path) private static function findClasses($path)
{ {
$extraTypes = version_compare(PHP_VERSION, '5.4', '<') ? '' : '|trait'; $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) { if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
$extraTypes .= '|enum'; $extraTypes .= '|enum';
} }

@ -377,11 +377,11 @@ EOT
$errors['ioncube'] = ioncube_loader_version(); $errors['ioncube'] = ioncube_loader_version();
} }
if (version_compare(PHP_VERSION, '5.3.2', '<')) { if (PHP_VERSION_ID < 50302) {
$errors['php'] = PHP_VERSION; $errors['php'] = PHP_VERSION;
} }
if (!isset($errors['php']) && version_compare(PHP_VERSION, '5.3.4', '<')) { if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
$warnings['php'] = PHP_VERSION; $warnings['php'] = PHP_VERSION;
} }

@ -548,7 +548,7 @@ EOT
} }
// php <5.3.3 has a very broken email validator, so bypass checks // php <5.3.3 has a very broken email validator, so bypass checks
if (version_compare(PHP_VERSION, '5.3.3', '<')) { if (PHP_VERSION_ID < 50303) {
return true; return true;
} }

@ -90,7 +90,7 @@ class Application extends BaseApplication
{ {
$this->io = new ConsoleIO($input, $output, $this->getHelperSet()); $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
if (version_compare(PHP_VERSION, '5.3.2', '<')) { if (PHP_VERSION_ID < 50302) {
$this->getIO()->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>'); $this->getIO()->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
} }

@ -182,7 +182,7 @@ class JsonFile
*/ */
public static function encode($data, $options = 448) public static function encode($data, $options = 448)
{ {
if (version_compare(PHP_VERSION, '5.4', '>=')) { if (PHP_VERSION_ID >= 50400) {
$json = json_encode($data, $options); $json = json_encode($data, $options);
if (false === $json) { if (false === $json) {
self::throwEncodeError(json_last_error()); self::throwEncodeError(json_last_error());

@ -214,7 +214,7 @@ class RemoteFilesystem
} }
if ($decode) { if ($decode) {
if (version_compare(PHP_VERSION, '5.4.0', '>=')) { if (PHP_VERSION_ID >= 50400) {
$result = zlib_decode($result); $result = zlib_decode($result);
} else { } else {
// work around issue with gzuncompress & co that do not work with all gzip checksums // work around issue with gzuncompress & co that do not work with all gzip checksums

@ -96,7 +96,7 @@ final class StreamContextFactory
// add SNI opts for https URLs // add SNI opts for https URLs
if ('https' === parse_url($url, PHP_URL_SCHEME)) { if ('https' === parse_url($url, PHP_URL_SCHEME)) {
$options['ssl']['SNI_enabled'] = true; $options['ssl']['SNI_enabled'] = true;
if (version_compare(PHP_VERSION, '5.6.0', '<')) { if (PHP_VERSION_ID < 50600) {
$options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST); $options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST);
} }
} }

@ -64,7 +64,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
array(__DIR__.'/Fixtures/template', array()), array(__DIR__.'/Fixtures/template', array()),
); );
if (version_compare(PHP_VERSION, '5.4', '>=')) { if (PHP_VERSION_ID >= 50400) {
$data[] = array(__DIR__.'/Fixtures/php5.4', array( $data[] = array(__DIR__.'/Fixtures/php5.4', array(
'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php',
'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php',

@ -150,7 +150,7 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase
public function testUnicode() public function testUnicode()
{ {
if (!function_exists('mb_convert_encoding') && version_compare(PHP_VERSION, '5.4', '<')) { if (!function_exists('mb_convert_encoding') && PHP_VERSION_ID < 50400) {
$this->markTestSkipped('Test requires the mbstring extension'); $this->markTestSkipped('Test requires the mbstring extension');
} }
@ -164,7 +164,7 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase
public function testOnlyUnicode() public function testOnlyUnicode()
{ {
if (!function_exists('mb_convert_encoding') && version_compare(PHP_VERSION, '5.4', '<')) { if (!function_exists('mb_convert_encoding') && PHP_VERSION_ID < 50400) {
$this->markTestSkipped('Test requires the mbstring extension'); $this->markTestSkipped('Test requires the mbstring extension');
} }

@ -146,7 +146,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
'SNI_server_name' => 'example.org' 'SNI_server_name' => 'example.org'
) )
); );
if (version_compare(PHP_VERSION, '5.6.0', '>=')) { if (PHP_VERSION_ID >= 50600) {
unset($expected['ssl']['SNI_server_name']); unset($expected['ssl']['SNI_server_name']);
} }
$this->assertEquals($expected, $options); $this->assertEquals($expected, $options);
@ -176,7 +176,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
'SNI_server_name' => 'example.org' 'SNI_server_name' => 'example.org'
) )
); );
if (version_compare(PHP_VERSION, '5.6.0', '>=')) { if (PHP_VERSION_ID >= 50600) {
unset($expected['ssl']['SNI_server_name']); unset($expected['ssl']['SNI_server_name']);
} }
$this->assertEquals($expected, $options); $this->assertEquals($expected, $options);

Loading…
Cancel
Save