minor #12554 compare version using PHP_VERSION_ID (xabbuh)
This PR was merged into the 2.5 branch.
Discussion
----------
compare version using PHP_VERSION_ID
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
This continues the work started in #12497 on the `2.3` branch.
Commits
-------
d2f846b
compare version using PHP_VERSION_ID
This commit is contained in:
commit
0dfa7d549e
@ -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';
|
||||
|
||||
|
@ -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.');
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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.');
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user