diff --git a/autoload.php.dist b/autoload.php.dist index 0bb2bc3a85271..689f140d093f4 100644 --- a/autoload.php.dist +++ b/autoload.php.dist @@ -1,6 +1,6 @@ =') && gc_enabled()) { +if (PHP_VERSION_ID >= 50400 && gc_enabled()) { // Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+ // https://bugs.php.net/bug.php?id=53976 gc_disable(); diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index 1df3e5da28cd8..cf7f1f576ad03 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -172,7 +172,7 @@ public function formatFile($file, $line, $text = null) $text = "$text at line $line"; if (false !== $link = $this->getFileLink($file, $line)) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php index 7b2cd4f9991d5..a4a4698ed8a50 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/FormThemeTest.php @@ -67,7 +67,7 @@ public function testCompile() protected function getVariableGetter($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php index 91c2f66b73716..38be27cfbed41 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php @@ -264,7 +264,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes() protected function getVariableGetter($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } diff --git a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php index e02637f237e38..df5eb559d8c21 100644 --- a/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php @@ -38,7 +38,7 @@ public function testCompileStrict() } protected function getVariableGetterWithoutStrictCheck($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : null)', $name, $name); } @@ -47,7 +47,7 @@ protected function getVariableGetterWithoutStrictCheck($name) protected function getVariableGetterWithStrictCheck($name) { - if (version_compare(phpversion(), '5.4.0RC1', '>=')) { + if (PHP_VERSION_ID >= 50400) { return sprintf('(isset($context["%s"]) ? $context["%s"] : $this->getContext($context, "%s"))', $name, $name, $name); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php index f05ec593ca33a..da66bb9615438 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php @@ -29,7 +29,7 @@ class ServerRunCommand extends ContainerAwareCommand */ public function isEnabled() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { return false; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index a72d5bf16af73..24c217f170fc1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -166,7 +166,7 @@ public function formatFile($file, $line, $text = null) } if (false !== $link = $this->getFileLink($file, $line)) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php index bb16373c1bbf6..5ec56deb3677e 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php @@ -30,7 +30,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c */ public function testRoutingErrorIsExposedWhenNotProtected($config) { - if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) { + if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { $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'); } @@ -46,7 +46,7 @@ public function testRoutingErrorIsExposedWhenNotProtected($config) */ public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config) { - if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) { + if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50309) { $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'); } diff --git a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php index 24a1d9769a2de..5b8ca598de830 100644 --- a/src/Symfony/Component/ClassLoader/ClassMapGenerator.php +++ b/src/Symfony/Component/ClassLoader/ClassMapGenerator.php @@ -11,7 +11,7 @@ namespace Symfony\Component\ClassLoader; -if (version_compare(PHP_VERSION, '5.4.0', '>=')) { +if (PHP_VERSION_ID >= 50400) { define('SYMFONY_TRAIT', T_TRAIT); } else { define('SYMFONY_TRAIT', 0); diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php index 7b71854da381d..587f36902fb9c 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php @@ -22,7 +22,7 @@ class ClassCollectionLoaderTest extends \PHPUnit_Framework_TestCase { public function testTraitDependencies() { - if (version_compare(phpversion(), '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Requires PHP > 5.4'); return; @@ -100,7 +100,7 @@ public function getDifferentOrders() */ public function testClassWithTraitsReordering(array $classes) { - if (version_compare(phpversion(), '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Requires PHP > 5.4'); return; diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index 06fa04e45405b..e49cfdcf9b135 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -104,7 +104,7 @@ public function getTestCreateMapTests() )), ); - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { $data[] = array(__DIR__.'/Fixtures/php5.4', array( 'TFoo' => __DIR__.'/Fixtures/php5.4/traits.php', 'CFoo' => __DIR__.'/Fixtures/php5.4/traits.php', diff --git a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php index 2003237441cef..6a51519f7b1e5 100644 --- a/src/Symfony/Component/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -186,7 +186,7 @@ protected function describeApplication(Application $application, array $options */ private function formatDefaultValue($default) { - if (version_compare(PHP_VERSION, '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { return str_replace('\/', '/', json_encode($default)); } diff --git a/src/Symfony/Component/Debug/ErrorHandler.php b/src/Symfony/Component/Debug/ErrorHandler.php index c4954bda7a176..9987ae466306d 100644 --- a/src/Symfony/Component/Debug/ErrorHandler.php +++ b/src/Symfony/Component/Debug/ErrorHandler.php @@ -101,7 +101,7 @@ public function handle($level, $message, $file = 'unknown', $line = 0, $context if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) { if (isset(self::$loggers['deprecation'])) { - if (version_compare(PHP_VERSION, '5.4', '<')) { + if (PHP_VERSION_ID < 50400) { $stack = array_map( function ($row) { unset($row['args']); diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index acbeae600340d..c7864dc9619eb 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -288,7 +288,7 @@ private function abbrClass($class) */ private function formatArgs(array $args) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 50f00c1ff7b7a..6c1274ef35b16 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -530,7 +530,7 @@ public function html() $html = ''; foreach ($this->getNode(0)->childNodes as $child) { - if (version_compare(PHP_VERSION, '5.3.6', '>=')) { + if (PHP_VERSION_ID >= 50306) { // node parameter was added to the saveHTML() method in PHP 5.3.6 // @see http://php.net/manual/en/domdocument.savehtml.php $html .= $child->ownerDocument->saveHTML($child); diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php index 11ffd3791d4b9..4a84e01a525c5 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php @@ -69,7 +69,7 @@ public function __construct($inputTimezone = null, $outputTimezone = null, $form // The pipe in the parser pattern only works as of PHP 5.3.7 // See http://bugs.php.net/54316 $this->parseUsingPipe = null === $parseUsingPipe - ? version_compare(phpversion(), '5.3.7', '>=') + ? PHP_VERSION_ID >= 50307 : $parseUsingPipe; // See http://php.net/manual/en/datetime.createfromformat.php diff --git a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php index f0a74b49628ac..6b4ff984af5ce 100644 --- a/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php +++ b/src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php @@ -65,7 +65,7 @@ public function isCsrfTokenValid($intention, $token) */ protected function getSessionId() { - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { if (PHP_SESSION_NONE === session_status()) { session_start(); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php index d6a6568b86a90..dbcdad0f96bdf 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php @@ -60,7 +60,7 @@ public function dataProvider() ); // This test will fail < 5.3.9 - see https://bugs.php.net/51994 - if (version_compare(phpversion(), '5.3.9', '>=')) { + if (PHP_VERSION_ID >= 50309) { $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'); } @@ -111,7 +111,7 @@ public function testTransformExpectsDateTime() */ public function testReverseTransformUsingPipe($format, $input, $output) { - if (version_compare(phpversion(), '5.3.7', '<')) { + if (PHP_VERSION_ID < 50307) { $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php index a99b544406fca..3cf62f8db3081 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/DefaultCsrfProviderTest.php @@ -49,7 +49,7 @@ public function testGenerateCsrfTokenOnUnstartedSession() { session_id('touti'); - if (!version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('This test requires PHP >= 5.4'); } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 0e5d07184ea3f..4eec9cc38f836 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -324,7 +324,7 @@ public function send() while (($level = ob_get_level()) > 0 && $level !== $previous) { $previous = $level; if ($obStatus[$level - 1]) { - if (version_compare(PHP_VERSION, '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { if (isset($obStatus[$level - 1]['flags']) && ($obStatus[$level - 1]['flags'] & PHP_OUTPUT_HANDLER_REMOVABLE)) { ob_end_flush(); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php index 22acdecf61047..0319e0f802fab 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php @@ -17,7 +17,7 @@ * @see http://php.net/sessionhandler */ -if (version_compare(phpversion(), '5.4.0', '>=')) { +if (PHP_VERSION_ID >= 50400) { class NativeSessionHandler extends \SessionHandler { } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index f15ced587dc07..b1766503f18a9 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -100,7 +100,7 @@ public function __construct(array $options = array(), $handler = null, MetadataB session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used) ini_set('session.use_cookies', 1); - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { session_register_shutdown(); } else { register_shutdown_function('session_write_close'); @@ -130,11 +130,11 @@ public function start() return true; } - if (version_compare(phpversion(), '5.4.0', '>=') && \PHP_SESSION_ACTIVE === session_status()) { + if (PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) { throw new \RuntimeException('Failed to start the session: already started by PHP.'); } - if (version_compare(phpversion(), '5.4.0', '<') && isset($_SESSION) && session_id()) { + if (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id()) { // not 100% fool-proof, but is the most reliable way to determine if a session is active in PHP 5.3 throw new \RuntimeException('Failed to start the session: already started by PHP ($_SESSION is set).'); } @@ -366,13 +366,13 @@ public function setSaveHandler($saveHandler = null) if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { $saveHandler = new SessionHandlerProxy($saveHandler); } elseif (!$saveHandler instanceof AbstractProxy) { - $saveHandler = version_compare(phpversion(), '5.4.0', '>=') ? + $saveHandler = PHP_VERSION_ID >= 50400 ? new SessionHandlerProxy(new \SessionHandler()) : new NativeProxy(); } $this->saveHandler = $saveHandler; if ($this->saveHandler instanceof \SessionHandlerInterface) { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { session_set_save_handler($this->saveHandler, false); } else { session_set_save_handler( diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php index 0b7e5648c0f1f..a46355aac4cb4 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php @@ -72,7 +72,7 @@ public function isWrapper() */ public function isActive() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { return $this->active = \PHP_SESSION_ACTIVE === session_status(); } @@ -93,7 +93,7 @@ public function isActive() */ public function setActive($flag) { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { throw new \LogicException('This method is disabled in PHP 5.4.0+'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php index 20cefabf497bc..3f96bdf025732 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeFileSessionHandlerTest.php @@ -27,7 +27,7 @@ public function testConstruct() { $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir())); - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName()); $this->assertEquals('files', ini_get('session.save_handler')); } else { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php index 7880615db0be5..8fba843b7dd56 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/NativeSessionHandlerTest.php @@ -28,7 +28,7 @@ public function testConstruct() // note for PHPUnit optimisers - the use of assertTrue/False // here is deliberate since the tests do not require the classes to exist - drak - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->assertFalse($handler instanceof \SessionHandler); $this->assertTrue($handler instanceof NativeSessionHandler); } else { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 4870115caa64c..ca8d28e337e34 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -164,7 +164,7 @@ public function testSetSaveHandlerException() public function testSetSaveHandler53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -186,7 +186,7 @@ public function testSetSaveHandler53() public function testSetSaveHandler54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -211,7 +211,7 @@ public function testSetSaveHandler54() */ public function testStartedOutside53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -234,7 +234,7 @@ public function testStartedOutside53() */ public function testCanStartOutside54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index 0510f3fe9a5a8..e712632589bf6 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php @@ -60,7 +60,7 @@ protected function getStorage() public function testPhpSession53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -84,7 +84,7 @@ public function testPhpSession53() public function testPhpSession54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php index f8ac39c94c1d3..1df28cf1a2c92 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/AbstractProxyTest.php @@ -87,7 +87,7 @@ public function testIsWrapper() public function testIsActivePhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -99,7 +99,7 @@ public function testIsActivePhp53() */ public function testIsActivePhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -110,7 +110,7 @@ public function testIsActivePhp54() public function testSetActivePhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -126,7 +126,7 @@ public function testSetActivePhp53() */ public function testSetActivePhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -149,7 +149,7 @@ public function testName() */ public function testNameExceptionPhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -163,7 +163,7 @@ public function testNameExceptionPhp53() */ public function testNameExceptionPhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } @@ -187,7 +187,7 @@ public function testId() */ public function testIdExceptionPhp53() { - if (version_compare(phpversion(), '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestSkipped('Test skipped, for PHP 5.3 only.'); } @@ -201,7 +201,7 @@ public function testIdExceptionPhp53() */ public function testIdExceptionPhp54() { - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('Test skipped, for PHP 5.4 only.'); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 74d841906025b..be9b110d02e10 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -52,7 +52,7 @@ public function testOpen() $this->assertFalse($this->proxy->isActive()); $this->proxy->open('name', 'id'); - if (version_compare(phpversion(), '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->assertTrue($this->proxy->isActive()); } else { $this->assertFalse($this->proxy->isActive()); diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 4f53f3cf5ea1d..e4ee7cea22805 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -107,7 +107,7 @@ public function render($uri, Request $request, array $options = array()) } $renderedAttributes = ''; if (count($attributes) > 0) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php index 652546e3930e7..b9e9f277cf6fc 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php @@ -188,7 +188,7 @@ public function testGetArguments() $request->attributes->set('foobar', 'foobar'); $controller = array(new self(), 'controllerMethod3'); - if (version_compare(PHP_VERSION, '5.3.16', '==')) { + if (PHP_VERSION_ID === 50316) { $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system'); } else { try { diff --git a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php index 2af08157353f1..6a79340c695e4 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php @@ -35,7 +35,7 @@ public function write($path, $locale, $data) } }); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { // Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs file_put_contents( $path.'/'.$locale.'.json', diff --git a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php index dcd418bbb7d83..32d01c4f1f09e 100644 --- a/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php +++ b/src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php @@ -200,7 +200,7 @@ public function format($timestamp) { // intl allows timestamps to be passed as arrays - we don't if (is_array($timestamp)) { - $message = version_compare(PHP_VERSION, '5.3.4', '>=') ? + $message = PHP_VERSION_ID >= 50304 ? 'Only integer Unix timestamps and DateTime objects are supported' : 'Only integer Unix timestamps are supported'; @@ -209,11 +209,11 @@ public function format($timestamp) // behave like the intl extension $argumentError = null; - if (version_compare(PHP_VERSION, '5.3.4', '<') && !is_int($timestamp)) { + if (PHP_VERSION_ID < 50304 && !is_int($timestamp)) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value '; - } elseif (version_compare(PHP_VERSION, '5.3.4', '>=') && !is_int($timestamp) && !$timestamp instanceof \DateTime) { + } elseif (PHP_VERSION_ID >= 50304 && !is_int($timestamp) && !$timestamp instanceof \DateTime) { $argumentError = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object'; - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=') && !is_int($timestamp)) { + if (PHP_VERSION_ID >= 50500 && !is_int($timestamp)) { $argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp); } } @@ -227,7 +227,7 @@ public function format($timestamp) } // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (version_compare(PHP_VERSION, '5.3.4', '>=') && $timestamp instanceof \DateTime) { + if (PHP_VERSION_ID >= 50304 && $timestamp instanceof \DateTime) { $timestamp = $timestamp->getTimestamp(); } @@ -376,7 +376,7 @@ public function getTimeZoneId() } // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { return date_default_timezone_get(); } } @@ -541,7 +541,7 @@ public function setTimeZoneId($timeZoneId) { if (null === $timeZoneId) { // In PHP 5.5 if $timeZoneId is null it fallbacks to `date_default_timezone_get()` method - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $timeZoneId = date_default_timezone_get(); } else { // TODO: changes were made to ext/intl in PHP 5.4.4 release that need to be investigated since it will diff --git a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php index fe7d3206247a5..d908aff34ce29 100644 --- a/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php +++ b/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php @@ -816,10 +816,7 @@ private function getInt64Value($value) // The negative PHP_INT_MAX was being converted to float if ( $value == self::$int32Range['negative'] && - ( - (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) || - version_compare(PHP_VERSION, '5.4.4', '>=') - ) + ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) ) { return (int) $value; } @@ -832,10 +829,7 @@ private function getInt64Value($value) // A 32 bit integer was being generated instead of a 64 bit integer if ( ($value > self::$int32Range['positive'] || $value < self::$int32Range['negative']) && - ( - (version_compare(PHP_VERSION, '5.3.14', '<')) || - (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) - ) + (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) ) { $value = (-2147483648 - ($value % -2147483648)) * ($value / abs($value)); } diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php index 73d6c20821032..69575289cdd9f 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php @@ -34,7 +34,7 @@ class JsonBundleWriterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - if (version_compare(PHP_VERSION, '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { $this->markTestSkipped('This test requires at least PHP 5.4.0.'); } @@ -47,7 +47,7 @@ protected function setUp() protected function tearDown() { - if (version_compare(PHP_VERSION, '5.4.0', '<')) { + if (PHP_VERSION_ID < 50400) { return; } diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php index 2c6f5558fffa2..dd4e4cd129b51 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php @@ -37,7 +37,7 @@ public function testConstructorDefaultTimeZone() $formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT); // In PHP 5.5 default timezone depends on `date_default_timezone_get()` method - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $this->assertEquals(date_default_timezone_get(), $formatter->getTimeZoneId()); } else { $this->assertNull($formatter->getTimeZoneId()); @@ -238,7 +238,7 @@ public function formatProvider() ); // As of PHP 5.3.4, IntlDateFormatter::format() accepts DateTime instances - if (version_compare(PHP_VERSION, '5.3.4', '>=')) { + if (PHP_VERSION_ID >= 50304) { $dateTime = new \DateTime('@0'); /* general, DateTime */ @@ -269,7 +269,7 @@ public function testFormatIllegalArgumentError($pattern, $timestamp, $errorMessa public function formatErrorProvider() { // With PHP 5.5 IntlDateFormatter accepts empty values ('0') - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { return array( array('y-M-d', 'foobar', 'datefmt_format: string \'foobar\' is not numeric, which would be required for it to be a valid date: U_ILLEGAL_ARGUMENT_ERROR'), ); @@ -277,7 +277,7 @@ public function formatErrorProvider() $message = 'datefmt_format: takes either an array or an integer timestamp value : U_ILLEGAL_ARGUMENT_ERROR'; - if (version_compare(PHP_VERSION, '5.3.4', '>=')) { + if (PHP_VERSION_ID >= 50304) { $message = 'datefmt_format: takes either an array or an integer timestamp value or a DateTime object: U_ILLEGAL_ARGUMENT_ERROR'; } @@ -326,7 +326,7 @@ public function formatWithTimezoneProvider() ); // As of PHP 5.5, intl ext no longer fallbacks invalid time zones to UTC - if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID < 50500) { // When time zone not exists, uses UTC by default $data[] = array(0, 'Foo/Bar', '1970-01-01 00:00:00'); $data[] = array(0, 'UTC+04:30', '1970-01-01 00:00:00'); @@ -340,7 +340,7 @@ public function testFormatWithGmtTimezone() { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone('GMT+03:00'); } else { $formatter->setTimeZoneId('GMT+03:00'); @@ -353,7 +353,7 @@ public function testFormatWithGmtTimeZoneAndMinutesOffset() { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone('GMT+00:30'); } else { $formatter->setTimeZoneId('GMT+00:30'); @@ -366,7 +366,7 @@ public function testFormatWithNonStandardTimezone() { $formatter = $this->getDefaultDateFormatter('zzzz'); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone('Pacific/Fiji'); } else { $formatter->setTimeZoneId('Pacific/Fiji'); @@ -388,7 +388,7 @@ public function testFormatWithConstructorTimezone() public function testFormatWithTimezoneFromEnvironmentVariable() { - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $this->markTestSkipped('IntlDateFormatter in PHP 5.5 no longer depends on TZ environment.'); } @@ -411,7 +411,7 @@ public function testFormatWithTimezoneFromEnvironmentVariable() public function testFormatWithTimezoneFromPhp() { - if (!version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID < 50500) { $this->markTestSkipped('Only in PHP 5.5 IntlDateFormatter depends on default timezone (`date_default_timezone_get()`).'); } @@ -842,7 +842,7 @@ public function testSetTimeZoneId($timeZoneId, $expectedTimeZoneId) { $formatter = $this->getDefaultDateFormatter(); - if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) { + if (PHP_VERSION_ID >= 50500) { $formatter->setTimeZone($timeZoneId); } else { $formatter->setTimeZoneId($timeZoneId); diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php index 68235a5429ed6..2e7544b39e008 100644 --- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php @@ -57,7 +57,7 @@ public function testFormatWithUnsupportedTimestampArgument() } catch (\Exception $e) { $this->assertInstanceOf('Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException', $e); - if (version_compare(PHP_VERSION, '5.3.4', '>=')) { + if (PHP_VERSION_ID >= 50304) { $this->assertStringEndsWith('Only integer Unix timestamps and DateTime objects are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); } else { $this->assertStringEndsWith('Only integer Unix timestamps are supported. Please install the "intl" extension for full localization capabilities.', $e->getMessage()); diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php index 32f0579908c70..e94d0c70328e5 100644 --- a/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php +++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php @@ -593,10 +593,7 @@ public function testParseTypeInt64With32BitIntegerInPhp32Bit() // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // The negative PHP_INT_MAX was being converted to float - if ( - (version_compare(PHP_VERSION, '5.4.0', '<') && version_compare(PHP_VERSION, '5.3.14', '>=')) || - version_compare(PHP_VERSION, '5.4.4', '>=') - ) { + if ((PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50314) || PHP_VERSION_ID >= 50404) { $this->assertInternalType('int', $parsedValue); } else { $this->assertInternalType('float', $parsedValue); @@ -653,10 +650,7 @@ public function testParseTypeInt64With64BitIntegerInPhp64Bit() // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // A 32 bit integer was being generated instead of a 64 bit integer - if ( - (version_compare(PHP_VERSION, '5.3.14', '<')) || - (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) - ) { + if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { $this->assertEquals(-2147483648, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); } else { $this->assertEquals(2147483648, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); @@ -667,10 +661,7 @@ public function testParseTypeInt64With64BitIntegerInPhp64Bit() // Bug #59597 was fixed on PHP 5.3.14 and 5.4.4 // A 32 bit integer was being generated instead of a 64 bit integer - if ( - (version_compare(PHP_VERSION, '5.3.14', '<')) || - (version_compare(PHP_VERSION, '5.4.0', '>=') && version_compare(PHP_VERSION, '5.4.4', '<')) - ) { + if (PHP_VERSION_ID < 50314 || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50404)) { $this->assertEquals(2147483647, $parsedValue, '->parse() TYPE_INT64 does not use true 64 bit integers, using only the 32 bit range (PHP < 5.3.14 and PHP < 5.4.4).'); } else { $this->assertEquals(-2147483649, $parsedValue, '->parse() TYPE_INT64 uses true 64 bit integers (PHP >= 5.3.14 and PHP >= 5.4.4).'); diff --git a/src/Symfony/Component/Security/Core/Util/SecureRandom.php b/src/Symfony/Component/Security/Core/Util/SecureRandom.php index 841b9af38b886..aefc88854a648 100644 --- a/src/Symfony/Component/Security/Core/Util/SecureRandom.php +++ b/src/Symfony/Component/Security/Core/Util/SecureRandom.php @@ -43,7 +43,7 @@ public function __construct($seedFile = null, LoggerInterface $logger = null) $this->logger = $logger; // determine whether to use OpenSSL - if (defined('PHP_WINDOWS_VERSION_BUILD') && version_compare(PHP_VERSION, '5.3.4', '<')) { + if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) { $this->useOpenSsl = false; } elseif (!function_exists('openssl_random_pseudo_bytes')) { if (null !== $this->logger) { diff --git a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php index dd962fd095858..61e2afef18c21 100644 --- a/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php +++ b/src/Symfony/Component/Security/Tests/Core/Encoder/BCryptPasswordEncoderTest.php @@ -66,7 +66,7 @@ public function testValidation() private function skipIfPhpVersionIsNotSupported() { - if (version_compare(phpversion(), '5.3.7', '<')) { + if (PHP_VERSION_ID < 50307) { $this->markTestSkipped('Requires PHP >= 5.3.7'); } } diff --git a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php index 91b465535e9bc..e94a1a9b1ff97 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonDecode.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonDecode.php @@ -92,7 +92,7 @@ public function decode($data, $format, array $context = array()) $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + if (PHP_VERSION_ID >= 50400) { $decodedData = json_decode($data, $associative, $recursionDepth, $options); } else { $decodedData = json_decode($data, $associative, $recursionDepth); diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 42eebebe1a73d..288fddc70f015 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -462,7 +462,7 @@ public function getGlobals() protected function initializeEscapers() { $that = $this; - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $flags = ENT_QUOTES | ENT_SUBSTITUTE; } else { $flags = ENT_QUOTES; diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index eda6efae08f1a..f5b5e6b4566c0 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -125,7 +125,7 @@ private function updateRepr() } if (null !== $this->parsedFile) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; } else { $jsonOptions = 0; diff --git a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php index a45fb76313716..8c2b1a49a93f3 100644 --- a/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParseExceptionTest.php @@ -19,7 +19,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase public function testGetMessage() { $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml'); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")'; } else { $message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")'; @@ -31,7 +31,7 @@ public function testGetMessage() public function testGetMessageWithUnicodeInFilename() { $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml'); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (PHP_VERSION_ID >= 50400) { $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")'; } else { $message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';