From 29ca21f30ecb45f83bc15a3f7fd8edc06e4f67f8 Mon Sep 17 00:00:00 2001 From: Possum Date: Tue, 5 May 2015 20:18:24 +0200 Subject: [PATCH] PHP version checks tweaking --- src/Composer/Autoload/ClassMapGenerator.php | 2 +- src/Composer/Command/DiagnoseCommand.php | 4 ++-- src/Composer/Command/InitCommand.php | 2 +- src/Composer/Console/Application.php | 2 +- src/Composer/Json/JsonFile.php | 2 +- src/Composer/Util/RemoteFilesystem.php | 2 +- src/Composer/Util/StreamContextFactory.php | 2 +- tests/Composer/Test/Autoload/ClassMapGeneratorTest.php | 2 +- tests/Composer/Test/Json/JsonFileTest.php | 4 ++-- tests/Composer/Test/Util/StreamContextFactoryTest.php | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 656ce15b1..0f05f45ff 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -112,7 +112,7 @@ class ClassMapGenerator */ 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', '>=')) { $extraTypes .= '|enum'; } diff --git a/src/Composer/Command/DiagnoseCommand.php b/src/Composer/Command/DiagnoseCommand.php index 9e4f8863d..b770c6faf 100644 --- a/src/Composer/Command/DiagnoseCommand.php +++ b/src/Composer/Command/DiagnoseCommand.php @@ -377,11 +377,11 @@ EOT $errors['ioncube'] = ioncube_loader_version(); } - if (version_compare(PHP_VERSION, '5.3.2', '<')) { + if (PHP_VERSION_ID < 50302) { $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; } diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 70411736a..971477306 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -548,7 +548,7 @@ EOT } // 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; } diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 12bb08dc7..9896afe42 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -90,7 +90,7 @@ class Application extends BaseApplication { $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); - if (version_compare(PHP_VERSION, '5.3.2', '<')) { + if (PHP_VERSION_ID < 50302) { $this->getIO()->writeError('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.'); } diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index cf9dea5f4..1c51a4251 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -182,7 +182,7 @@ class JsonFile */ public static function encode($data, $options = 448) { - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { $json = json_encode($data, $options); if (false === $json) { self::throwEncodeError(json_last_error()); diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 99abf5f22..c2bff9369 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -214,7 +214,7 @@ class RemoteFilesystem } if ($decode) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $result = zlib_decode($result); } else { // work around issue with gzuncompress & co that do not work with all gzip checksums diff --git a/src/Composer/Util/StreamContextFactory.php b/src/Composer/Util/StreamContextFactory.php index 5bcb431ca..ffeaf3f83 100644 --- a/src/Composer/Util/StreamContextFactory.php +++ b/src/Composer/Util/StreamContextFactory.php @@ -96,7 +96,7 @@ final class StreamContextFactory // add SNI opts for https URLs if ('https' === parse_url($url, PHP_URL_SCHEME)) { $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); } } diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index b8efc0c80..fc21593b7 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -64,7 +64,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase array(__DIR__.'/Fixtures/template', array()), ); - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { $data[] = array(__DIR__.'/Fixtures/php5.4', array( 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', diff --git a/tests/Composer/Test/Json/JsonFileTest.php b/tests/Composer/Test/Json/JsonFileTest.php index 64a621d6c..ff0b1565e 100644 --- a/tests/Composer/Test/Json/JsonFileTest.php +++ b/tests/Composer/Test/Json/JsonFileTest.php @@ -150,7 +150,7 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase 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'); } @@ -164,7 +164,7 @@ class JsonFileTest extends \PHPUnit_Framework_TestCase 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'); } diff --git a/tests/Composer/Test/Util/StreamContextFactoryTest.php b/tests/Composer/Test/Util/StreamContextFactoryTest.php index afb6bfc7e..2cc419670 100644 --- a/tests/Composer/Test/Util/StreamContextFactoryTest.php +++ b/tests/Composer/Test/Util/StreamContextFactoryTest.php @@ -146,7 +146,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase 'SNI_server_name' => 'example.org' ) ); - if (version_compare(PHP_VERSION, '5.6.0', '>=')) { + if (PHP_VERSION_ID >= 50600) { unset($expected['ssl']['SNI_server_name']); } $this->assertEquals($expected, $options); @@ -176,7 +176,7 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase 'SNI_server_name' => 'example.org' ) ); - if (version_compare(PHP_VERSION, '5.6.0', '>=')) { + if (PHP_VERSION_ID >= 50600) { unset($expected['ssl']['SNI_server_name']); } $this->assertEquals($expected, $options);