minor #15867 Normalize the way we check versions (romainneutron)
This PR was merged into the 2.7 branch.
Discussion
----------
Normalize the way we check versions
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | N/A
| License | MIT
Commits
-------
121eade
Normalize the way we check versions
This commit is contained in:
commit
6d9cba8ae5
@ -80,7 +80,7 @@ if ($this->env->isDebug()) {
|
||||
}
|
||||
|
||||
EOTXT;
|
||||
$expected = preg_replace('/%(.*?)%/', version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected);
|
||||
$expected = preg_replace('/%(.*?)%/', PHP_VERSION_ID >= 50400 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected);
|
||||
|
||||
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
||||
}
|
||||
@ -106,7 +106,7 @@ if ($this->env->isDebug()) {
|
||||
}
|
||||
|
||||
EOTXT;
|
||||
$expected = preg_replace('/%(.*?)%/', version_compare(PHP_VERSION, '5.4.0') >= 0 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected);
|
||||
$expected = preg_replace('/%(.*?)%/', PHP_VERSION_ID >= 50400 ? '(isset($context["$1"]) ? $context["$1"] : null)' : '$this->getContext($context, "$1")', $expected);
|
||||
|
||||
$this->assertSame($expected, $compiler->compile($node)->getSource());
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ abstract class ServerCommand extends ContainerAwareCommand
|
||||
*/
|
||||
public function isEnabled()
|
||||
{
|
||||
if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) {
|
||||
if (PHP_VERSION_ID < 50400 || defined('HHVM_VERSION')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ abstract class AbstractComparisonValidatorTestCase extends AbstractConstraintVal
|
||||
{
|
||||
protected static function addPhp5Dot5Comparisons(array $comparisons)
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '<')) {
|
||||
if (PHP_VERSION_ID < 50500) {
|
||||
return $comparisons;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class IdenticalToValidatorTest extends AbstractComparisonValidatorTestCase
|
||||
array(null, 1),
|
||||
);
|
||||
|
||||
if (version_compare(PHP_VERSION, '>=', '5.5')) {
|
||||
if (PHP_VERSION_ID => 50500) {
|
||||
$immutableDate = new \DateTimeImmutable('2000-01-01');
|
||||
$comparisons[] = array($immutableDate, $immutableDate);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||
array(new \DateTime('March 20, 2014')),
|
||||
);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$tests[] = array(new \DateTimeImmutable('March 10, 2014'));
|
||||
$tests[] = array(new \DateTimeImmutable('March 15, 2014'));
|
||||
$tests[] = array(new \DateTimeImmutable('March 20, 2014'));
|
||||
@ -216,7 +216,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||
array(new \DateTime('March 9, 2014'), 'Mar 9, 2014, 12:00 AM'),
|
||||
);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$tests[] = array(new \DateTimeImmutable('March 20, 2013'), 'Mar 20, 2013, 12:00 AM');
|
||||
$tests[] = array(new \DateTimeImmutable('March 9, 2014'), 'Mar 9, 2014, 12:00 AM');
|
||||
}
|
||||
@ -237,7 +237,7 @@ class RangeValidatorTest extends AbstractConstraintValidatorTest
|
||||
array(new \DateTime('March 9, 2015'), 'Mar 9, 2015, 12:00 AM'),
|
||||
);
|
||||
|
||||
if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
|
||||
if (PHP_VERSION_ID >= 50500) {
|
||||
$tests[] = array(new \DateTimeImmutable('March 21, 2014'), 'Mar 21, 2014, 12:00 AM');
|
||||
$tests[] = array(new \DateTimeImmutable('March 9, 2015'), 'Mar 9, 2015, 12:00 AM');
|
||||
}
|
||||
|
Reference in New Issue
Block a user