compare version using PHP_VERSION_ID

This continues the work started in #12497 on the `2.3` branch.
This commit is contained in:
Christian Flothmann 2014-11-23 21:10:39 +01:00
parent 5284b59fb9
commit d2f846b453
12 changed files with 16 additions and 16 deletions

View File

@ -474,7 +474,7 @@ class Configuration implements ConfigurationInterface
// API version already during container configuration
// (to adjust service classes etc.)
// See https://github.com/symfony/symfony/issues/11580
$v['validation']['api'] = version_compare(PHP_VERSION, '5.3.9', '<')
$v['validation']['api'] = PHP_VERSION_ID < 50309
? '2.4'
: '2.5-bc';

View File

@ -17,7 +17,7 @@ class JsonDescriptorTest extends AbstractDescriptorTest
{
protected function setUp()
{
if (version_compare(phpversion(), '5.4.0', '<')) {
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('Test skipped on PHP 5.3 as JSON_PRETTY_PRINT does not exist.');
}
}

View File

@ -129,7 +129,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
'api' => version_compare(PHP_VERSION, '5.3.9', '<') ? '2.4' : '2.5-bc',
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
),
'annotations' => array(
'cache' => 'file',

View File

@ -280,7 +280,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
$this->assertSame('setApiVersion', $calls[6][0]);
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
} else {
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
@ -433,7 +433,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
@ -457,7 +457,7 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertSame('setApiVersion', $calls[5][0]);
// no cache, no annotations
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
} else {
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);

View File

@ -336,7 +336,7 @@ class Parser
$node = new Node\GetAttrNode($node, $arg, $arguments, $type);
} elseif ('[' === $token->value) {
if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && version_compare(PHP_VERSION, '5.4.0', '<')) {
if ($node instanceof Node\GetAttrNode && Node\GetAttrNode::METHOD_CALL === $node->attributes['type'] && PHP_VERSION_ID < 50400) {
throw new SyntaxError('Array calls on a method call is only supported on PHP 5.4+', $token->cursor);
}

View File

@ -51,7 +51,7 @@ class NativeSessionTokenStorageTest extends \PHPUnit_Framework_TestCase
public function testStoreTokenInClosedSessionWithExistingSessionId()
{
if (version_compare(PHP_VERSION, '5.4', '<')) {
if (PHP_VERSION_ID < 50400) {
$this->markTestSkipped('This test requires PHP 5.4 or later.');
}

View File

@ -108,7 +108,7 @@ class NativeSessionTokenStorage implements TokenStorageInterface
private function startSession()
{
if (version_compare(PHP_VERSION, '5.4', '>=')) {
if (PHP_VERSION_ID >= 50400) {
if (PHP_SESSION_NONE === session_status()) {
session_start();
}

View File

@ -18,7 +18,7 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
{
public function testDump()
{
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
if (PHP_VERSION_ID < 50400) {
$this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing');
}

View File

@ -21,7 +21,7 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
{
protected function setUp()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}

View File

@ -21,7 +21,7 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
{
protected function setUp()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}

View File

@ -112,7 +112,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testDefaultApiVersion()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
// Old implementation on PHP < 5.3.9
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
} else {
@ -135,7 +135,7 @@ class ValidatorBuilderTest extends \PHPUnit_Framework_TestCase
public function testSetApiVersion24And25()
{
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
if (PHP_VERSION_ID < 50309) {
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
}

View File

@ -325,7 +325,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
));
}
if (version_compare(PHP_VERSION, '5.3.9', '<') && $apiVersion === Validation::API_VERSION_2_5_BC) {
if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) {
throw new InvalidArgumentException(sprintf(
'The Validator API that is compatible with both Symfony 2.4 '.
'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '.
@ -385,7 +385,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface
$apiVersion = $this->apiVersion;
if (null === $apiVersion) {
$apiVersion = version_compare(PHP_VERSION, '5.3.9', '<')
$apiVersion = PHP_VERSION_ID < 50309
? Validation::API_VERSION_2_4
: Validation::API_VERSION_2_5_BC;
}