diff --git a/packages/zend-db/library/Zend/Db/Adapter/Pdo/Mysql.php b/packages/zend-db/library/Zend/Db/Adapter/Pdo/Mysql.php index 6cbb1e08e..b62989ed3 100644 --- a/packages/zend-db/library/Zend/Db/Adapter/Pdo/Mysql.php +++ b/packages/zend-db/library/Zend/Db/Adapter/Pdo/Mysql.php @@ -102,7 +102,7 @@ protected function _connect() } if (!empty($this->_config['charset']) - && version_compare(PHP_VERSION, '5.3.6', '<') + && PHP_VERSION_ID < 50306 ) { $initCommand = "SET NAMES '" . $this->_config['charset'] . "'"; $this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND diff --git a/packages/zend-loader/library/Zend/Loader/AutoloaderFactory.php b/packages/zend-loader/library/Zend/Loader/AutoloaderFactory.php index 651ec0e89..8cd9df28f 100644 --- a/packages/zend-loader/library/Zend/Loader/AutoloaderFactory.php +++ b/packages/zend-loader/library/Zend/Loader/AutoloaderFactory.php @@ -114,7 +114,7 @@ public static function factory($options = null) // unfortunately is_subclass_of is broken on some 5.3 versions // additionally instanceof is also broken for this use case - if (version_compare(PHP_VERSION, '5.3.7', '>=')) { + if (PHP_VERSION_ID >= 50307) { if (!is_subclass_of($class, 'Zend_Loader_SplAutoloader')) { // require_once 'Exception/InvalidArgumentException.php'; throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( diff --git a/packages/zend-loader/library/Zend/Loader/StandardAutoloader.php b/packages/zend-loader/library/Zend/Loader/StandardAutoloader.php index a461e4c4c..3a871968e 100644 --- a/packages/zend-loader/library/Zend/Loader/StandardAutoloader.php +++ b/packages/zend-loader/library/Zend/Loader/StandardAutoloader.php @@ -314,7 +314,7 @@ protected function loadClass($class, $type) if ($type === self::ACT_AS_FALLBACK) { // create filename $filename = $this->transformClassNameToFilename($class, ''); - if (version_compare(PHP_VERSION, '5.3.2', '>=')) { + if (PHP_VERSION_ID >= 50302) { $resolvedName = stream_resolve_include_path($filename); if ($resolvedName !== false) { return include $resolvedName; diff --git a/packages/zend-mobile/library/Zend/Mobile/Push/Apns.php b/packages/zend-mobile/library/Zend/Mobile/Push/Apns.php index 7dd04ff3f..65b6c5631 100644 --- a/packages/zend-mobile/library/Zend/Mobile/Push/Apns.php +++ b/packages/zend-mobile/library/Zend/Mobile/Push/Apns.php @@ -313,8 +313,8 @@ public function send(Zend_Mobile_Push_Message_Abstract $message) foreach($message->getCustomData() as $k => $v) { $payload[$k] = $v; } - - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + + if (PHP_VERSION_ID >= 50400) { $payload = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } else { $payload = json_encode($payload); diff --git a/packages/zend-mobile/library/Zend/Mobile/Push/Message/Gcm.php b/packages/zend-mobile/library/Zend/Mobile/Push/Message/Gcm.php index 18edaa651..df6e160a7 100644 --- a/packages/zend-mobile/library/Zend/Mobile/Push/Message/Gcm.php +++ b/packages/zend-mobile/library/Zend/Mobile/Push/Message/Gcm.php @@ -268,7 +268,7 @@ public function toJson() if ($this->_ttl !== 2419200) { $json['time_to_live'] = $this->_ttl; } - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + if (PHP_VERSION_ID >= 50400) { return json_encode($json, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } else { return json_encode($json); diff --git a/packages/zend-stdlib/library/Zend/Stdlib/CallbackHandler.php b/packages/zend-stdlib/library/Zend/Stdlib/CallbackHandler.php index 377f1ddc8..1d63edb49 100644 --- a/packages/zend-stdlib/library/Zend/Stdlib/CallbackHandler.php +++ b/packages/zend-stdlib/library/Zend/Stdlib/CallbackHandler.php @@ -184,7 +184,7 @@ public function call(array $args = array()) { $callback = $this->getCallback(); - $isPhp54 = version_compare(PHP_VERSION, '5.4.0rc1', '>='); + $isPhp54 = PHP_VERSION_ID >= 50400; if ($isPhp54 && is_string($callback)) { $this->validateStringCallbackFor54($callback); diff --git a/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php b/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php index 343e1a8c7..2c8956904 100644 --- a/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php +++ b/packages/zend-wildfire/library/Zend/Wildfire/Plugin/FirePhp.php @@ -534,7 +534,7 @@ protected function _getStackTrace($options) $spliceOffset = 2; //Debug backtrace changed in PHP 7.0.0 - if (version_compare(PHP_VERSION, '7.0.0', '>=')) { + if (PHP_VERSION_ID >= 70000) { $spliceOffset = 1; } $trace = array_splice($trace, $spliceOffset); diff --git a/packages/zend-xml/library/Zend/Xml/Security.php b/packages/zend-xml/library/Zend/Xml/Security.php index 48e6d341a..1a052cf1b 100644 --- a/packages/zend-xml/library/Zend/Xml/Security.php +++ b/packages/zend-xml/library/Zend/Xml/Security.php @@ -179,18 +179,9 @@ public static function scanFile($file, DOMDocument $dom = null) */ public static function isPhpFpm() { - $isVulnerableVersion = ( - version_compare(PHP_VERSION, '5.5.22', 'lt') - || ( - version_compare(PHP_VERSION, '5.6', 'ge') - && version_compare(PHP_VERSION, '5.6.6', 'lt') - ) - ); + $isVulnerableVersion = PHP_VERSION_ID < 50522 || (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50606); - if (substr(php_sapi_name(), 0, 3) === 'fpm' && $isVulnerableVersion) { - return true; - } - return false; + return $isVulnerableVersion && strpos(php_sapi_name(), 'fpm') === 0; } /** diff --git a/tests/Zend/Amf/RequestTest.php b/tests/Zend/Amf/RequestTest.php index 84a6320e6..ef451f500 100644 --- a/tests/Zend/Amf/RequestTest.php +++ b/tests/Zend/Amf/RequestTest.php @@ -436,7 +436,7 @@ public function testAmf0MixedArrayParameterDeserializedToNativePhpObject() // In PHP versions less than 7, get_object_vars doesn't return numerical // keys. In PHP 7.2+ array_key_exists on this particular object returns false // https://3v4l.org/ui8Fm - if (version_compare(PHP_VERSION, '7.0.0', '>=')) { + if (PHP_VERSION_ID >= 70000) { $this->assertTrue(array_key_exists(1, get_object_vars($data[0]))); } else { $this->assertTrue(array_key_exists(1, $data[0])); diff --git a/tests/Zend/Date/DateObjectTest.php b/tests/Zend/Date/DateObjectTest.php index 0d13cfccf..5ff49bf4c 100644 --- a/tests/Zend/Date/DateObjectTest.php +++ b/tests/Zend/Date/DateObjectTest.php @@ -284,7 +284,7 @@ public function testCalcSunInternal() // (which was later reverted in php < 7.2.0) // Example of the difference: https://3v4l.org/v46rk // Not really something we can test the same in all versions, so doing a version_compare here. - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if (PHP_VERSION_ID >= 70200) { $this->assertSame( 9961716, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, true )); $this->assertSame(10010341, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, false)); $this->assertSame( 9966981, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true )); @@ -321,7 +321,7 @@ public function testCalcSunInternal() } $date = new Zend_Date_DateObjectTestHelper(-148309884); - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if (PHP_VERSION_ID >= 70200) { $this->assertSame(-148322626, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, true )); $this->assertSame(-148274784, $date->calcSun(array('latitude' => 38.4, 'longitude' => -29), -0.0145439, false)); $this->assertSame(-148318143, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true )); diff --git a/tests/Zend/DateTest.php b/tests/Zend/DateTest.php index ecdbd1633..1e461d6a2 100644 --- a/tests/Zend/DateTest.php +++ b/tests/Zend/DateTest.php @@ -3821,7 +3821,9 @@ public function testSunFunc() // PHP's internal sunrise/sunset calculation changed in 7.2.0 // See comment in Zend/Date/DateObjectTest.php::testCalcSunInternal // This applies to all of the version_compare blocks in this test - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + $isPhp72 = PHP_VERSION_ID >= 70200; + + if ($isPhp72) { $this->assertSame('2002-01-04T20:09:40+05:00', $result->get(Zend_Date::W3C)); } else { $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date::W3C)); @@ -3831,7 +3833,7 @@ public function testSunFunc() $result = Zend_Date_Cities::City('vienna', 'civil'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if ($isPhp72) { $this->assertSame('2002-01-04T20:09:01+05:00', $result->get(Zend_Date::W3C)); } else { $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date::W3C)); @@ -3841,7 +3843,7 @@ public function testSunFunc() $result = Zend_Date_Cities::City('vienna', 'nautic'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if ($isPhp72) { $this->assertSame('2002-01-04T20:08:15+05:00', $result->get(Zend_Date::W3C)); } else { $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date::W3C)); @@ -3851,7 +3853,7 @@ public function testSunFunc() $result = Zend_Date_Cities::City('vienna', 'astronomic'); $this->assertTrue(is_array($result)); $result = $date->getSunset($result); - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if ($isPhp72) { $this->assertSame('2002-01-04T20:07:30+05:00', $result->get(Zend_Date::W3C)); } else { $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date::W3C)); @@ -3861,7 +3863,7 @@ public function testSunFunc() $result = Zend_Date_Cities::City('BERLIN'); $this->assertTrue(is_array($result)); $result = $date->getSunrise($result); - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if ($isPhp72) { $this->assertSame('2002-01-04T12:21:26+05:00', $result->get(Zend_Date::W3C)); } else { $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date::W3C)); @@ -3871,7 +3873,7 @@ public function testSunFunc() $result = Zend_Date_Cities::City('London'); $this->assertTrue(is_array($result)); $result = $date->getSunInfo($result); - if (version_compare(PHP_VERSION, '7.2.0', '>=')) { + if ($isPhp72) { $this->assertSame('2002-01-04T13:10:15+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C )); $this->assertSame('2002-01-04T13:10:59+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C )); $this->assertSame('2002-01-04T13:11:50+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C )); diff --git a/tests/Zend/Filter/HtmlEntitiesTest.php b/tests/Zend/Filter/HtmlEntitiesTest.php index debcf46e9..8fde7dc18 100644 --- a/tests/Zend/Filter/HtmlEntitiesTest.php +++ b/tests/Zend/Filter/HtmlEntitiesTest.php @@ -214,7 +214,7 @@ public function testQuoteStyleQuotesEncodeNone() */ public function testCorrectsForEncodingMismatch() { - if (version_compare(phpversion(), '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestIncomplete('Tested feature ZF-11344 is not available because of PHP bug #63450'); } @@ -234,7 +234,7 @@ public function testCorrectsForEncodingMismatch() */ public function testStripsUnknownCharactersWhenEncodingMismatchDetected() { - if (version_compare(phpversion(), '5.4', '>=')) { + if (PHP_VERSION_ID >= 50400) { $this->markTestIncomplete('Tested feature ZF-11344 is not available because of PHP bug #63450'); } diff --git a/tests/Zend/Ldap/ConverterTest.php b/tests/Zend/Ldap/ConverterTest.php index 3f2eb0f68..8b08eb722 100644 --- a/tests/Zend/Ldap/ConverterTest.php +++ b/tests/Zend/Ldap/ConverterTest.php @@ -112,7 +112,7 @@ public function testToLdapSerialize($expect, $convert){ } public function toLdapSerializeProvider(){ - if (getenv('CI') && version_compare(PHP_VERSION, '5.4.0', '>=')) { + if (getenv('CI') && PHP_VERSION_ID >= 50400) { return array( array('N;', null), array('i:1;', 1), @@ -121,7 +121,7 @@ public function toLdapSerializeProvider(){ ); } - if (version_compare(PHP_VERSION, '5.6.0beta4', '>=')) { + if (PHP_VERSION_ID >= 50400) { return array( array('N;', null), array('i:1;', 1), diff --git a/tests/Zend/Loader/AutoloaderFactoryTest.php b/tests/Zend/Loader/AutoloaderFactoryTest.php index b095ec376..32cdb121c 100644 --- a/tests/Zend/Loader/AutoloaderFactoryTest.php +++ b/tests/Zend/Loader/AutoloaderFactoryTest.php @@ -106,7 +106,7 @@ public function testRegisteringValidMapFilePopulatesAutoloader() */ public function testFactoryCatchesInvalidClasses() { - if (!version_compare(PHP_VERSION, '5.3.7', '>=')) { + if (PHP_VERSION_ID < 50307) { $this->markTestSkipped('Cannot test invalid interface loader with versions less than 5.3.7'); } include dirname(__FILE__) . '/_files/InvalidInterfaceAutoloader.php'; diff --git a/tests/Zend/Log/Writer/AbstractTest.php b/tests/Zend/Log/Writer/AbstractTest.php index 3cd099503..670100f06 100644 --- a/tests/Zend/Log/Writer/AbstractTest.php +++ b/tests/Zend/Log/Writer/AbstractTest.php @@ -58,7 +58,7 @@ protected function setUp() */ public function testSetFormatter() { - if (version_compare(phpversion(), '7', '>=')) { + if (PHP_VERSION_ID >= 70000) { $this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+'); } diff --git a/tests/Zend/Log/Writer/DbTest.php b/tests/Zend/Log/Writer/DbTest.php index b4dff8fd2..843351bfd 100644 --- a/tests/Zend/Log/Writer/DbTest.php +++ b/tests/Zend/Log/Writer/DbTest.php @@ -138,7 +138,7 @@ public function testFactory() */ public function testThrowStrictSetFormatter() { - if (version_compare(phpversion(), '7', '>=')) { + if (PHP_VERSION_ID >= 70000) { $this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+'); } diff --git a/tests/Zend/Serializer/Adapter/PhpCodeTest.php b/tests/Zend/Serializer/Adapter/PhpCodeTest.php index 7f91851d1..f16a92cf3 100644 --- a/tests/Zend/Serializer/Adapter/PhpCodeTest.php +++ b/tests/Zend/Serializer/Adapter/PhpCodeTest.php @@ -145,7 +145,7 @@ public function testUnserializeObject() public function testUnserialzeInvalid() { - if (version_compare(phpversion(), '7', '>=')) { + if (PHP_VERSION_ID >= 70000) { $this->markTestSkipped('Evaling of invalid input is PHP Parse error in PHP7+'); } $value = 'not a serialized string'; diff --git a/tests/Zend/Soap/AllTests.php b/tests/Zend/Soap/AllTests.php index cc9c9db07..d45212f95 100644 --- a/tests/Zend/Soap/AllTests.php +++ b/tests/Zend/Soap/AllTests.php @@ -53,7 +53,7 @@ public static function suite() //early exit because of segfault in this specific version //https://github.com/zendframework/zf1/issues/650 - if (getenv('CI') && version_compare(PHP_VERSION, '5.4.37', '=')) { + if (getenv('CI') && PHP_VERSION_ID >= 50437) { return $suite; }