8000 compare version using PHP_VERSION_ID · symfony/symfony@d2f846b · GitHub
[go: up one dir, main page]

Skip to content

Commit d2f846b

Browse files
committed
compare version using PHP_VERSION_ID
This continues the work started in #12497 on the `2.3` branch.
1 parent 5284b59 commit d2f846b

File tree

12 files changed

+16
-16
lines changed

12 files changed

+16
-16
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
474474
// API version already during container configuration
475475
// (to adjust service classes etc.)
476476
// See https://github.com/symfony/symfony/issues/11580
477-
$v['validation']['api'] = version_compare(PHP_VERSION, '5.3.9', '<')
477+
$v['validation']['api'] = PHP_VERSION_ID < 50309
478478
? '2.4'
479479
: '2.5-bc';
480480

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/JsonDescriptorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class JsonDescriptorTest extends AbstractDescriptorTest
1717
{
1818
protected function setUp()
1919
{
20-
if (version_compare(phpversion(), '5.4.0', '<')) {
20+
if (PHP_VERSION_ID < 50400) {
2121
$this->markTestSkipped('Test skipped on PHP 5.3 as JSON_PRETTY_PRINT does not exist.');
2222
}
2323
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected static function getBundleDefaultConfig()
129129
'static_method' => array('loadValidatorMetadata'),
130130
'translation_domain' => 'validators',
131131
'strict_email' => false,
132-
'api' => version_compare(PHP_VERSION, '5.3.9', '<') ? '2.4' : '2.5-bc',
132+
'api' => PHP_VERSION_ID < 50309 ? '2.4' : '2.5-bc',
133133
),
134134
'annotations' => array(
135135
'cache' => 'file',

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function testValidation()
280280
$this->assertEquals(array(new Reference('validator.mapping.cache.apc')), $calls[5][1]);
281281
$this->assertSame('setApiVersion', $calls[6][0]);
282282

283-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
283+
if (PHP_VERSION_ID < 50309) {
284284
$this->assertEquals(array(Validation::API_VERSION_2_4), $calls[6][1]);
285285
} else {
286286
$this->assertEquals(array(Validation::API_VERSION_2_5_BC), $calls[6][1]);
@@ -433,7 +433,7 @@ public function testValidationImplicitApi()
433433
$this->assertSame('setApiVersion', $calls[5][0]);
434434
// no cache, no annotations
435435

436-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
436+
if (PHP_VERSION_ID < 50309) {
437437
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
438438
} else {
439439
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);
@@ -457,7 +457,7 @@ public function testValidationAutoApi()
457457
$this->assertSame('setApiVersion', $calls[5][0]);
458458
// no cache, no annotations
459459

460-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
460+
if (PHP_VERSION_ID < 50309) {
461461
$this->assertSame(array(Validation::API_VERSION_2_4), $calls[5][1]);
462462
} else {
463463
$this->assertSame(array(Validation::API_VERSION_2_5_BC), $calls[5][1]);

src/Symfony/Component/ExpressionLanguage/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public function parsePostfixExpression($node)
336336

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

src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testStoreTokenInClosedSession()
5151

5252
public function testStoreTokenInClosedSessionWithExistingSessionId()
5353
{
54-
if (version_compare(PHP_VERSION, '5.4', '<')) {
54+
if (PHP_VERSION_ID < 50400) {
5555
$this->markTestSkipped('This test requires PHP 5.4 or later.');
5656
}
5757

src/Symfony/Component/Security/Csrf/TokenStorage/NativeSessionTokenStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function removeToken($tokenId)
108108

109109
private function startSession()
110110
{
111-
if (version_compare(PHP_VERSION, '5.4', '>=')) {
111+
if (PHP_VERSION_ID >= 50400) {
112112
if (PHP_SESSION_NONE === session_status()) {
113113
session_start();
114114
}

src/Symfony/Component/Translation/Tests/Dumper/JsonFileDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class JsonFileDumperTest extends \PHPUnit_Framework_TestCase
1818
{
1919
public function testDump()
2020
{
21-
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
21+
if (PHP_VERSION_ID < 50400) {
2222
$this->markTestIncomplete('PHP below 5.4 doesn\'t support JSON pretty printing');
2323
}
2424

src/Symfony/Component/Validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LegacyValidator2Dot5ApiTest extends Abstract2Dot5ApiTest
2121
{
2222
protected function setUp()
2323
{
24-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
10000
24+
if (PHP_VERSION_ID < 50309) {
2525
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
2626
}
2727

src/Symfony/Component/Validator/Tests/Validator/LegacyValidatorLegacyApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LegacyValidatorLegacyApiTest extends AbstractLegacyApiTest
2121
{
2222
protected function setUp()
2323
{
24-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
24+
if (PHP_VERSION_ID < 50309) {
2525
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
2626
}
2727

src/Symfony/Component/Validator/Tests/ValidatorBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function testSetTranslationDomain()
112112

113113
public function testDefaultApiVersion()
114114
{
115-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
115+
if (PHP_VERSION_ID < 50309) {
116116
// Old implementation on PHP < 5.3.9
117117
$this->assertInstanceOf('Symfony\Component\Validator\Validator', $this->builder->getValidator());
118118
} else {
@@ -135,7 +135,7 @@ public function testSetApiVersion25()
135135

136136
public function testSetApiVersion24And25()
137137
{
138-
if (version_compare(PHP_VERSION, '5.3.9', '<')) {
138+
if (PHP_VERSION_ID < 50309) {
139139
$this->markTestSkipped('Not supported prior to PHP 5.3.9');
140140
}
141141

src/Symfony/Component/Validator/ValidatorBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public function setApiVersion($apiVersion)
325325
));
326326
}
327327

328-
if (version_compare(PHP_VERSION, '5.3.9', '<') && $apiVersion === Validation::API_VERSION_2_5_BC) {
328+
if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) {
329329
throw new InvalidArgumentException(sprintf(
330330
'The Validator API that is compatible with both Symfony 2.4 '.
331331
'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. '.
@@ -385,7 +385,7 @@ public function getValidator()
385385
$apiVersion = $this->apiVersion;
386386

387387
if (null === $apiVersion) {
388-
$apiVersion = version_compare(PHP_VERSION, '5.3.9', '<')
388+
$apiVersion = PHP_VERSION_ID < 50309
389389
? Validation::API_VERSION_2_4
390390
: Validation::API_VERSION_2_5_BC;
391391
}

0 commit comments

Comments
 (0)
0