Skip to content

Commit 77f115e

Browse files
committed
minor symfony#12497 compare version using PHP_VERSION_ID (xabbuh)
This PR was merged into the 2.3 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 | To let opcode caches optimize cached code, the `PHP_VERSION_ID` constant is used to detect the current PHP version instead of calling `version_compare()` with `PHP_VERSION`. Commits ------- 367ed3c compare version using PHP_VERSION_ID
2 parents fa71441 + 367ed3c commit 77f115e

File tree

44 files changed

+85
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+85
-100
lines changed

autoload.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
if (version_compare(PHP_VERSION, '5.4', '>=') && gc_enabled()) {
3+
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
44
// Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
55
// https://bugs.php.net/bug.php?id=53976
66
gc_disable();

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function formatFile($file, $line, $text = null)
172172
$text = "$text at line $line";
173173

174174
if (false !== $link = $this->getFileLink($file, $line)) {
175-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
175+
if (PHP_VERSION_ID >= 50400) {
176176
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
177177
} else {
178178
$flags = ENT_QUOTES;

src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testCompile()
6767

6868
protected function getVariableGetter($name)
6969
{
70-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
70+
if (PHP_VERSION_ID >= 50400) {
7171
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
7272
}
7373

src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
264264

265265
protected function getVariableGetter($name)
266266
{
267-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
267+
if (PHP_VERSION_ID >= 50400) {
268268
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
269269
}
270270

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testCompileStrict()
3838
}
3939
protected function getVariableGetterWithoutStrictCheck($name)
4040
{
41-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
41+
if (PHP_VERSION_ID >= 50400) {
4242
return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name);
4343
}
4444

@@ -47,7 +47,7 @@ protected function getVariableGetterWithoutStrictCheck($name)
4747

4848
protected function getVariableGetterWithStrictCheck($name)
4949
{
50-
if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
50+
if (PHP_VERSION_ID >= 50400) {
5151
return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name);
5252
}
5353

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ServerRunCommand extends ContainerAwareCommand
2929
*/
3030
public function isEnabled()
3131
{
32-
if (version_compare(phpversion(), '5.4.0', '<')) {
32+
if (PHP_VERSION_ID < 50400) {
3333
return false;
3434
}
3535

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function formatFile($file, $line, $text = null)
166166
}
167167

168168
if (false !== $link = $this->getFileLink($file, $line)) {
169-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
169+
if (PHP_VERSION_ID >= 50400) {
170170
$flags = ENT_QUOTES | ENT_SUBSTITUTE;
171171
} else {
172172
$flags = ENT_QUOTES;

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
3030
*/
3131
public function testRoutingErrorIsExposedWhenNotProtected($config)
3232
{
33-
if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
33+
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
3434
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
3535
}
3636

@@ -46,7 +46,7 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
4646
*/
4747
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
4848
{
49-
if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
49+
if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) {
5050
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
5151
}
5252

src/Symfony/Component/ClassLoader/ClassMapGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
14+
if (PHP_VERSION_ID >= 50400) {
1515
define('SYMFONY_TRAIT', T_TRAIT);
1616
} else {
1717
define('SYMFONY_TRAIT', 0);

src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase
2222
{
2323
public function testTraitDependencies()
2424
{
25-
if (version_compare(phpversion(), '5.4', '<')) {
25+
if (PHP_VERSION_ID < 50400) {
2626
$this->markTestSkipped('Requires PHP > 5.4');
2727

2828
return;
@@ -100,7 +100,7 @@ public function getDifferentOrders()
100100
*/
101101
public function testClassWithTraitsReordering(array $classes)
102102
{
103-
if (version_compare(phpversion(), '5.4', '<')) {
103+
if (PHP_VERSION_ID < 50400) {
104104
$this->markTestSkipped('Requires PHP > 5.4');
105105

106106
return;

0 commit comments

Comments
 (0)