From 71ba4faf90f64654fdf67c1983d0aa7ad97cd0fc Mon Sep 17 00:00:00 2001 From: Jay Klehr Date: Fri, 12 Jan 2018 15:58:54 -0700 Subject: [PATCH 1/9] PHP 7.2 support --- .gitignore | 1 + demos/Zend/Mobile/Push/ApnsFeedback.php | 6 +++--- .../manual/en/module_specs/Zend_Mobile_Push-Apns.xml | 4 ++-- library/Zend/Cache/Backend.php | 2 +- library/Zend/Config/Yaml.php | 10 ++++++---- .../Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php | 2 +- library/Zend/Rest/Route.php | 10 ++++++---- library/Zend/XmlRpc/Value.php | 10 +++++++--- tests/Zend/XmlRpc/RequestTest.php | 4 ++-- 9 files changed, 29 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 6a23764604..629b39bf59 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ tests/Zend/Translate/Adapter/_files/zend_cache---testid tests/TestConfiguration.php tests/Zend/Session/_files/* tests/Zend/Cache/zend_cache_tmp_dir_* +tests/Zend/Config/Writer/temp/* vendor/* composer.lock bin/dbunit diff --git a/demos/Zend/Mobile/Push/ApnsFeedback.php b/demos/Zend/Mobile/Push/ApnsFeedback.php index e2b5489eb0..79c07622e0 100644 --- a/demos/Zend/Mobile/Push/ApnsFeedback.php +++ b/demos/Zend/Mobile/Push/ApnsFeedback.php @@ -3,7 +3,7 @@ $apns = new Zend_Mobile_Push_Apns(); $apns->setCertificate('/path/to/provisioning-certificate.pem'); - + try { $apns->connect(Zend_Mobile_Push_Apns::SERVER_FEEDBACK_SANDBOX_URI); } catch (Zend_Mobile_Push_Exception_ServerUnavailable $e) { @@ -13,9 +13,9 @@ echo 'APNS Connection Error:' . $e->getMessage(); exit(1); } - + $tokens = $apns->feedback(); -while(list($token, $time) = each($tokens)) { +foreach ($tokens as $token => $time) { echo $time . "\t" . $token . PHP_EOL; } $apns->close(); diff --git a/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml b/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml index 7aa51c29be..f21f15d992 100644 --- a/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml +++ b/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml @@ -152,12 +152,12 @@ try { } $tokens = $apns->feedback(); -while(list($token, $time) = each($tokens)) { +foreach ($tokens as $token => $time) { echo $time . "\t" . $token . PHP_EOL; } $apns->close(); ]]> - + diff --git a/library/Zend/Cache/Backend.php b/library/Zend/Cache/Backend.php index 83f1af5f12..3d99e0939c 100644 --- a/library/Zend/Cache/Backend.php +++ b/library/Zend/Cache/Backend.php @@ -76,7 +76,7 @@ public function __construct(array $options = array()) public function setDirectives($directives) { if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array'); - while (list($name, $value) = each($directives)) { + foreach ($directives as $name => $value) { if (!is_string($name)) { Zend_Cache::throwException("Incorrect option name : $name"); } diff --git a/library/Zend/Config/Yaml.php b/library/Zend/Config/Yaml.php index 0d107033eb..6c3ff39599 100755 --- a/library/Zend/Config/Yaml.php +++ b/library/Zend/Config/Yaml.php @@ -202,7 +202,7 @@ public function __construct($yaml, $section = null, $options = false) if (!isset($config[$sectionName])) { require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception(sprintf( - 'Section "%s" cannot be found', + 'Section "%s" cannot be found', implode(' ', (array)$section) )); } @@ -214,7 +214,7 @@ public function __construct($yaml, $section = null, $options = false) if (!isset($config[$section])) { require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception(sprintf( - 'Section "%s" cannot be found', + 'Section "%s" cannot be found', implode(' ', (array)$section) )); } @@ -289,8 +289,10 @@ protected static function _decodeYaml($currentIndent, &$lines) { $config = array(); $inIndent = false; - while (list($n, $line) = each($lines)) { - $lineno = $n + 1; + while (key($lines) !== null) { + $line = current($lines); + $lineno = key($lines) + 1; + next($lines); $line = rtrim(preg_replace("/#.*$/", "", $line)); if (strlen($line) == 0) { diff --git a/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php b/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php index b23dc29d71..4448ed5d0e 100644 --- a/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php +++ b/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php @@ -88,7 +88,7 @@ public static function getAllCapabilities(TeraWurfl $wurflObj) if (!is_array($group)) { continue; } - while (list ($key, $value) = each($group)) { + foreach ($group as $key => $value) { if (is_bool($value)) { // to have the same type than the official WURFL API $features[$key] = ($value ? 'true' : 'false'); diff --git a/library/Zend/Rest/Route.php b/library/Zend/Rest/Route.php index 2b7cdd6241..c53da713d4 100644 --- a/library/Zend/Rest/Route.php +++ b/library/Zend/Rest/Route.php @@ -236,12 +236,14 @@ public function match($request, $partial = false) /** * Assembles user submitted parameters forming a URL path defined by this route * - * @param array $data An array of variable and value pairs used as parameters - * @param bool $reset Weither to reset the current params - * @param bool $encode Weither to return urlencoded string + * @param array $data An array of variable and value pairs used as parameters + * @param bool $reset Weither to reset the current params + * @param bool $encode Weither to return urlencoded string + * @param bool $partial + * * @return string Route path with user submitted parameters */ - public function assemble($data = array(), $reset = false, $encode = true) + public function assemble($data = array(), $reset = false, $encode = true, $partial = false) { if (!$this->_keysSet) { if (null === $this->_request) { diff --git a/library/Zend/XmlRpc/Value.php b/library/Zend/XmlRpc/Value.php index 6b22449964..e4d0435548 100644 --- a/library/Zend/XmlRpc/Value.php +++ b/library/Zend/XmlRpc/Value.php @@ -486,13 +486,17 @@ protected static function _createSimpleXMLElement(&$xml) */ protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value) { - list($type, $value) = each($xml); + $type = key($xml); + $value = current($xml); + next($xml); - if (!$type and $value === null) { + if ($type === null && $value === false) { $namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions'); foreach ($namespaces as $namespaceName => $namespaceUri) { $namespaceXml = $xml->children($namespaceUri); - list($type, $value) = each($namespaceXml); + $type = key($namespaceXml); + $value = current($namespaceXml); + next($namespaceXml); if ($type !== null) { $type = $namespaceName . ':' . $type; break; diff --git a/tests/Zend/XmlRpc/RequestTest.php b/tests/Zend/XmlRpc/RequestTest.php index dec3f4075c..1513a359a4 100644 --- a/tests/Zend/XmlRpc/RequestTest.php +++ b/tests/Zend/XmlRpc/RequestTest.php @@ -288,14 +288,14 @@ protected function _testXmlRequest($xml, $argv) $result = $sx->xpath('//methodName'); $count = 0; - while (list( , $node) = each($result)) { + foreach ($result as $node) { ++$count; } $this->assertEquals(1, $count, $xml); $result = $sx->xpath('//params'); $count = 0; - while (list( , $node) = each($result)) { + foreach ($result as $node) { ++$count; } $this->assertEquals(1, $count, $xml); From 3e0edb84dadb335c22515a278de8fc98cb1071dc Mon Sep 17 00:00:00 2001 From: Jay Klehr Date: Fri, 12 Jan 2018 16:52:40 -0700 Subject: [PATCH 2/9] fixing a number of other php 7.2 failures, still more to do --- .../Controller/Router/Route/ChainTest.php | 4 +-- tests/Zend/Form/FormTest.php | 33 ++++++++++--------- tests/Zend/Gdata/AppTest.php | 6 +++- tests/Zend/Queue/Stomp/ClientTest.php | 2 +- tests/Zend/TranslateTest.php | 2 +- .../Navigation/_files/mvc/views/bc.phtml | 4 +-- tests/Zend/View/Helper/PartialLoopTest.php | 21 ++++++++++-- 7 files changed, 46 insertions(+), 26 deletions(-) diff --git a/tests/Zend/Controller/Router/Route/ChainTest.php b/tests/Zend/Controller/Router/Route/ChainTest.php index 95134cb104..c17c936579 100644 --- a/tests/Zend/Controller/Router/Route/ChainTest.php +++ b/tests/Zend/Controller/Router/Route/ChainTest.php @@ -1015,7 +1015,7 @@ public function getVersion() return 2; } - public function assemble($data = array(), $reset = false, $encode = false) + public function assemble($data = array(), $reset = false, $encode = false, $partial = false) {} public static function getInstance(Zend_Config $config) @@ -1040,7 +1040,7 @@ public function getVersion() return 2; } - public function assemble($data = array(), $reset = false, $encode = false) + public function assemble($data = array(), $reset = false, $encode = false, $partial = false) {} public static function getInstance(Zend_Config $config) diff --git a/tests/Zend/Form/FormTest.php b/tests/Zend/Form/FormTest.php index 75fbeb65f0..b91332307b 100644 --- a/tests/Zend/Form/FormTest.php +++ b/tests/Zend/Form/FormTest.php @@ -2790,9 +2790,10 @@ public function testErrorMessagesFromProcessAjaxAreLocalizedWhenTranslateAdapter */ public function _setup9697() { - $callback = create_function('$value, $options', - 'return (isset($options["bar"]["quo"]["foo"]) && - "foo Value" === $options["bar"]["quo"]["foo"]);'); + $callback = function ($value, $options) { + return (isset($options["bar"]["quo"]["foo"]) && + "foo Value" === $options["bar"]["quo"]["foo"]); + }; $this->form->addElement('text', 'foo') ->foo->setBelongsTo('bar[quo]'); @@ -4596,7 +4597,7 @@ public function testIfViewIsSetInTime() } $this->assertNotEquals($result,''); } - + /** * @group ZF-11088 */ @@ -4608,7 +4609,7 @@ public function testAddErrorOnElementMakesFormInvalidAndReturnsCustomError() $errorMessages = $element->getErrorMessages(); $this->assertSame(1, count($errorMessages)); $this->assertSame($errorString, $errorMessages[0]); - + $element2 = new Zend_Form_Element_Text('bar'); $this->form->addElement($element2); $this->form->getElement('bar')->addError($errorString); @@ -4616,7 +4617,7 @@ public function testAddErrorOnElementMakesFormInvalidAndReturnsCustomError() $this->assertSame(1, count($errorMessages2)); $this->assertSame($errorString, $errorMessages2[0]); } - + /** * @group ZF-10865 * @expectedException Zend_Form_Exception @@ -4644,7 +4645,7 @@ public function testDashSeparatedElementsInDisplayGroupsShouldNotRenderOutsideDi $count = substr_count($html, 'randomelementname-element'); $this->assertEquals(1, $count, $html); } - + /** * @group ZF-11831 */ @@ -4659,7 +4660,7 @@ public function testElementsOfSubFormReceiveCorrectDefaultTranslator() 'locale' => 'en' )); Zend_Registry::set('Zend_Translate', $trDefault); - + // Translator to use for elements $trElement = new Zend_Translate(array( 'adapter' => 'array', @@ -4669,14 +4670,14 @@ public function testElementsOfSubFormReceiveCorrectDefaultTranslator() 'locale' => 'en' )); Zend_Validate_Abstract::setDefaultTranslator($trElement); - + // Change the form's translator $form = new Zend_Form(); $form->addElement(new Zend_Form_Element_Text('foo', array( 'required' => true, 'validators' => array('NotEmpty') ))); - + // Create a subform with it's own validator $sf1 = new Zend_Form_SubForm(); $sf1->addElement(new Zend_Form_Element_Text('foosub', array( @@ -4684,20 +4685,20 @@ public function testElementsOfSubFormReceiveCorrectDefaultTranslator() 'validators' => array('NotEmpty') ))); $form->addSubForm($sf1, 'Test1'); - + $form->isValid(array()); $messages = $form->getMessages(); $this->assertEquals( - 'Element', - @$messages['foo'][Zend_Validate_NotEmpty::IS_EMPTY], + 'Element', + @$messages['foo'][Zend_Validate_NotEmpty::IS_EMPTY], 'Form element received wrong validator' ); $this->assertEquals( - 'Element', - @$messages['Test1']['foosub'][Zend_Validate_NotEmpty::IS_EMPTY], + 'Element', + @$messages['Test1']['foosub'][Zend_Validate_NotEmpty::IS_EMPTY], 'SubForm element received wrong validator' - ); + ); } /** diff --git a/tests/Zend/Gdata/AppTest.php b/tests/Zend/Gdata/AppTest.php index 51466093d0..0d0d2a133d 100644 --- a/tests/Zend/Gdata/AppTest.php +++ b/tests/Zend/Gdata/AppTest.php @@ -608,7 +608,11 @@ public function testMagicConstructorsPropogateMinorVersion() { public function testLoadExtensionCausesFatalErrorWhenErrorHandlerIsOverridden() { // Override the error handler to throw an ErrorException - set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL); + set_error_handler( + function ($a, $b, $c, $d) { throw new ErrorException($b, 0, $a, $c, $d); }, + E_ALL + ); + try { $eq = $this->service->newEventQuery(); restore_error_handler(); diff --git a/tests/Zend/Queue/Stomp/ClientTest.php b/tests/Zend/Queue/Stomp/ClientTest.php index 38faa8db6a..36d2347aaa 100644 --- a/tests/Zend/Queue/Stomp/ClientTest.php +++ b/tests/Zend/Queue/Stomp/ClientTest.php @@ -54,7 +54,7 @@ class Zend_Queue_Stomp_Connection_Mock * @param array $config ('scheme', 'host', 'port') * @return true; */ - public function open($scheme, $host, $port) + public function open($scheme, $host, $port, array $options = array()) { if ( $port == 0 ) return false; return true; diff --git a/tests/Zend/TranslateTest.php b/tests/Zend/TranslateTest.php index 397f3d7633..749b25fe3c 100644 --- a/tests/Zend/TranslateTest.php +++ b/tests/Zend/TranslateTest.php @@ -637,7 +637,7 @@ public function testMultiClear() public function testEmptyTranslation() { $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, null, null, array('disableNotices' => true)); - $this->assertEquals(0, count($lang->getList())); + $this->assertNull($lang->getList()); } /** diff --git a/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml b/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml index dc66a5619f..b1659471ce 100644 --- a/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml +++ b/tests/Zend/View/Helper/Navigation/_files/mvc/views/bc.phtml @@ -1,4 +1,4 @@ getLabel();'), - $this->pages)); \ No newline at end of file + function ($a) { return $a->getLabel(); }, + $this->pages)); diff --git a/tests/Zend/View/Helper/PartialLoopTest.php b/tests/Zend/View/Helper/PartialLoopTest.php index 076ecda33f..ab45e8058b 100644 --- a/tests/Zend/View/Helper/PartialLoopTest.php +++ b/tests/Zend/View/Helper/PartialLoopTest.php @@ -402,7 +402,7 @@ public function testPartialLoopSetsTotalCount() } } -class Zend_View_Helper_PartialLoop_IteratorTest implements Iterator +class Zend_View_Helper_PartialLoop_IteratorTest implements Iterator, Countable { public $items; @@ -440,9 +440,14 @@ public function toArray() { return $this->items; } + + public function count() + { + return count($this->items); + } } -class Zend_View_Helper_PartialLoop_RecursiveIteratorTest implements Iterator +class Zend_View_Helper_PartialLoop_RecursiveIteratorTest implements Iterator, Countable { public $items; @@ -481,6 +486,11 @@ public function valid() { return (current($this->items) !== false); } + + public function count() + { + return count($this->items); + } } class Zend_View_Helper_PartialLoop_BogusIteratorTest @@ -500,7 +510,7 @@ public function toArray() } } -class Zend_View_Helper_PartialLoop_IteratorWithToArrayTest implements Iterator +class Zend_View_Helper_PartialLoop_IteratorWithToArrayTest implements Iterator, Countable { public $items; @@ -538,6 +548,11 @@ public function valid() { return (current($this->items) !== false); } + + public function count() + { + return count($this->items); + } } class Zend_View_Helper_PartialLoop_IteratorWithToArrayTestContainer From 66f24723fa2380c88bcc085ff2e3d997003a266f Mon Sep 17 00:00:00 2001 From: Jay Klehr Date: Fri, 12 Jan 2018 16:53:30 -0700 Subject: [PATCH 3/9] Removing php 7.2 from allowed failures --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1f03d32353..71bcc71b9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,4 +35,3 @@ script: matrix: allow_failures: - - php: 7.2 From dcb9205b36df39b9a4e0f13dcbf1d06f18ba90ae Mon Sep 17 00:00:00 2001 From: Jay Klehr Date: Fri, 12 Jan 2018 17:09:49 -0700 Subject: [PATCH 4/9] Fixing some countable warnings --- library/Zend/Feed/Reader/Entry/Rss.php | 2 +- library/Zend/Feed/Reader/Feed/Rss.php | 2 +- library/Zend/Test/DbStatement.php | 6 +++++- library/Zend/Tool/Project/Profile/Resource/Container.php | 2 +- library/Zend/Validate/File/Upload.php | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/library/Zend/Feed/Reader/Entry/Rss.php b/library/Zend/Feed/Reader/Entry/Rss.php index 52eaa3d206..1e4f334cd0 100644 --- a/library/Zend/Feed/Reader/Entry/Rss.php +++ b/library/Zend/Feed/Reader/Entry/Rss.php @@ -201,7 +201,7 @@ public function getAuthors() ); } - if (count($authors) == 0) { + if ($authors !== null && count($authors) == 0) { $authors = null; } diff --git a/library/Zend/Feed/Reader/Feed/Rss.php b/library/Zend/Feed/Reader/Feed/Rss.php index ab176246f0..2ec8a70847 100644 --- a/library/Zend/Feed/Reader/Feed/Rss.php +++ b/library/Zend/Feed/Reader/Feed/Rss.php @@ -151,7 +151,7 @@ public function getAuthors() ); } - if (count($authors) == 0) { + if ($authors !== null && count($authors) == 0) { $authors = null; } diff --git a/library/Zend/Test/DbStatement.php b/library/Zend/Test/DbStatement.php index cf36a8fac6..68bbc2f89f 100644 --- a/library/Zend/Test/DbStatement.php +++ b/library/Zend/Test/DbStatement.php @@ -140,7 +140,11 @@ public function setRowCount($rowCount) */ public function append($row) { - $this->_columnCount = count($row); + if (!is_array($row)) { + $this->_columnCount = 1; + } else { + $this->_columnCount = count($row); + } $this->_fetchStack[] = $row; } diff --git a/library/Zend/Tool/Project/Profile/Resource/Container.php b/library/Zend/Tool/Project/Profile/Resource/Container.php index 4f06f6f55d..ffbee3ebc0 100644 --- a/library/Zend/Tool/Project/Profile/Resource/Container.php +++ b/library/Zend/Tool/Project/Profile/Resource/Container.php @@ -383,7 +383,7 @@ public function valid() */ public function hasChildren() { - return (count($this->_subResources > 0)) ? true : false; + return (count($this->_subResources) > 0) ? true : false; } /** diff --git a/library/Zend/Validate/File/Upload.php b/library/Zend/Validate/File/Upload.php index 5eae769846..fde3414c93 100644 --- a/library/Zend/Validate/File/Upload.php +++ b/library/Zend/Validate/File/Upload.php @@ -129,7 +129,7 @@ public function getFiles($file = null) */ public function setFiles($files = array()) { - if (count($files) === 0) { + if ($files === null || count($files) === 0) { $this->_files = $_FILES; } else { $this->_files = $files; From 4e54d0687b893272d039b1ee8dab5ce01c0982f2 Mon Sep 17 00:00:00 2001 From: Jay Klehr Date: Sun, 14 Jan 2018 12:50:17 -0700 Subject: [PATCH 5/9] Fixing more Countable errors and some DebugTest differences --- .gitignore | 1 + library/Zend/Config/Yaml.php | 4 ++-- library/Zend/Mail/Part.php | 21 +++++++++++++-------- library/Zend/Oauth/Token.php | 2 +- tests/Zend/Db/Select/TestCommon.php | 3 ++- tests/Zend/DebugTest.php | 17 +++++++---------- tests/Zend/Mail/MessageTest.php | 14 +++++++------- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 629b39bf59..9e8ad0df94 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ vendor/* composer.lock bin/dbunit bin/phpunit +build/* diff --git a/library/Zend/Config/Yaml.php b/library/Zend/Config/Yaml.php index 6c3ff39599..86812051be 100755 --- a/library/Zend/Config/Yaml.php +++ b/library/Zend/Config/Yaml.php @@ -365,10 +365,10 @@ protected static function _parseValue($value) // remove quotes from string. if ('"' == $value['0']) { - if ('"' == $value[count($value) -1]) { + if ('"' == $value[strlen($value) -1]) { $value = substr($value, 1, -1); } - } elseif ('\'' == $value['0'] && '\'' == $value[count($value) -1]) { + } elseif ('\'' == $value['0'] && '\'' == $value[strlen($value) -1]) { $value = strtr($value, array("''" => "'", "'" => '')); } diff --git a/library/Zend/Mail/Part.php b/library/Zend/Mail/Part.php index ca881a791e..3056bb35a8 100644 --- a/library/Zend/Mail/Part.php +++ b/library/Zend/Mail/Part.php @@ -47,7 +47,7 @@ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface +class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface, Countable { /** * headers of part as array @@ -96,10 +96,10 @@ class Zend_Mail_Part implements RecursiveIterator, Zend_Mail_Part_Interface * @var int */ protected $_messageNum = 0; - + /** * Class to use when creating message parts - * @var string + * @var string */ protected $_partClass; @@ -138,7 +138,7 @@ public function __construct(array $params) $this->_mail = $params['handler']; $this->_messageNum = $params['id']; } - + if (isset($params['partclass'])) { $this->setPartClass($params['partclass']); } @@ -162,7 +162,7 @@ public function __construct(array $params) } } } - + /** * Set name pf class used to encapsulate message parts * @param string $class @@ -184,14 +184,14 @@ public function setPartClass($class) require_once 'Zend/Mail/Exception.php'; throw new Zend_Mail_Exception("Class '{$class}' must implement Zend_Mail_Part_Interface"); } - + $this->_partClass = $class; return $this; } - + /** * Retrieve the class name used to encapsulate message parts - * @return string + * @return string */ public function getPartClass() { @@ -579,6 +579,11 @@ public function rewind() $this->_iterationPos = 1; } + public function count() + { + return $this->countParts(); + } + /** * Ensure headers do not contain invalid characters * diff --git a/library/Zend/Oauth/Token.php b/library/Zend/Oauth/Token.php index 08f23e5c12..52a1f8697a 100644 --- a/library/Zend/Oauth/Token.php +++ b/library/Zend/Oauth/Token.php @@ -71,7 +71,7 @@ public function __construct( if ($response !== null) { $this->_response = $response; $params = $this->_parseParameters($response); - if (count($params) > 0) { + if ($params !== null && count($params) > 0) { $this->setParams($params); } } diff --git a/tests/Zend/Db/Select/TestCommon.php b/tests/Zend/Db/Select/TestCommon.php index bf13aa623e..340791ffff 100644 --- a/tests/Zend/Db/Select/TestCommon.php +++ b/tests/Zend/Db/Select/TestCommon.php @@ -363,7 +363,8 @@ public function testSelectColumnWithColonQuotedParameter() $stmt = $select = $this->_selectColumnWithColonQuotedParameter() ->query(); $result = $stmt->fetchAll(); - $this->assertEquals(0, count($result)); + + $this->assertNull($result); } /** diff --git a/tests/Zend/DebugTest.php b/tests/Zend/DebugTest.php index d543b81ffe..c2333a3e39 100644 --- a/tests/Zend/DebugTest.php +++ b/tests/Zend/DebugTest.php @@ -51,8 +51,8 @@ public function testDebugDump() $data = 'string'; $result = Zend_Debug::Dump($data, null, false); $result = str_replace(array(PHP_EOL, "\n"), '_', $result); - $expected = "__string(6) \"string\"__"; - $this->assertEquals($expected, $result); + $expected = "__.*string\(6\) \"string\"__"; + $this->assertRegExp('/^' . $expected . '$/', $result); } public function testDebugCgi() @@ -61,12 +61,9 @@ public function testDebugCgi() $data = 'string'; $result = Zend_Debug::Dump($data, null, false); - // Has to check for two strings, because xdebug internally handles CLI vs Web - $this->assertContains($result, - array( - "
string(6) \"string\"\n
", - "
string(6) "string"\n
", - ) + $this->assertRegExp( + '/^
.*string\(6\) ("|")string("|")' . "\n" . '<\/pre>$/s',
+            $result
         );
     }
 
@@ -90,8 +87,8 @@ public function testDebugDumpLabel()
         $label = 'LABEL';
         $result = Zend_Debug::Dump($data, $label, false);
         $result = str_replace(array(PHP_EOL, "\n"), '_', $result);
-        $expected = "_{$label} _string(6) \"string\"__";
-        $this->assertEquals($expected, $result);
+        $expected = "_{$label} .*_string\(6\) \"string\"__";
+        $this->assertRegExp('/^' . $expected . '$/', $result);
     }
 
     /**
diff --git a/tests/Zend/Mail/MessageTest.php b/tests/Zend/Mail/MessageTest.php
index 195cdca844..cbffe5f67a 100644
--- a/tests/Zend/Mail/MessageTest.php
+++ b/tests/Zend/Mail/MessageTest.php
@@ -458,7 +458,7 @@ public function testSpaceInFieldName()
         $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'foo'), 'bar');
         $this->assertEquals(Zend_Mime_Decode::splitHeaderField($header, 'baz'), 42);
     }
-    
+
     /**
      * @group ZF-11514
      */
@@ -474,7 +474,7 @@ public function testConstructorMergesConstructorFlagsIntoDefaultFlags()
         $this->assertArrayHasKey('constructor', $flags);
         $this->assertEquals('constructor', $flags['constructor']);
     }
-    
+
     /**
      * @group ZF-3745
      */
@@ -486,7 +486,7 @@ public function testBackwardsCompatibilityMaintainedWhenPartClassNotSpecified()
             $this->assertEquals('Zend_Mail_Part', get_class($part));
         }
     }
-    
+
     /**
      * @group ZF-3745
      */
@@ -497,14 +497,14 @@ public function testMessageAcceptsPartClassOverrideViaConstructor()
             'partclass' => 'ZF3745_Mail_Part'
         ));
         $this->assertEquals('ZF3745_Mail_Part', $message->getPartClass());
-        
+
         // Ensure message parts use the specified part class
         $this->assertGreaterThan(0, count($message));
         foreach ( $message as $part ) {
             $this->assertEquals('ZF3745_Mail_Part', get_class($part));
         }
     }
-    
+
     /**
      * @group ZF-3745
      */
@@ -513,7 +513,7 @@ public function testMessageAcceptsPartClassOverrideViaSetter()
         $message = new Zend_Mail_Message(array('file' => $this->_file));
         $message->setPartClass('ZF3745_Mail_Part');
         $this->assertEquals('ZF3745_Mail_Part', $message->getPartClass());
-        
+
         // Ensure message parts use the specified part class
         $this->assertGreaterThan(0, count($message));
         foreach ( $message as $part ) {
@@ -529,7 +529,7 @@ public function invalidHeaders()
             'multi-value' => array('Fake', array('okay', "foo-bar\r\n\r\nevilContent")),
         );
     }
-    
+
     /**
      * @dataProvider invalidHeaders
      * @group ZF2015-04

From 8c8baf4a4cf76a6c7906d2bb3e0e2b577a0eb6f1 Mon Sep 17 00:00:00 2001
From: Jay Klehr 
Date: Sun, 14 Jan 2018 13:13:53 -0700
Subject: [PATCH 6/9] Fixing DB test assertion

---
 tests/Zend/Db/Select/TestCommon.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tests/Zend/Db/Select/TestCommon.php b/tests/Zend/Db/Select/TestCommon.php
index 340791ffff..0b02e919ee 100644
--- a/tests/Zend/Db/Select/TestCommon.php
+++ b/tests/Zend/Db/Select/TestCommon.php
@@ -364,7 +364,11 @@ public function testSelectColumnWithColonQuotedParameter()
             ->query();
         $result = $stmt->fetchAll();
 
-        $this->assertNull($result);
+        if (is_array($result)) {
+            $this->assertEquals(0, count($result));
+        } else {
+            $this->assertNull($result);
+        }
     }
 
     /**

From d6588d95c06556774d20940ebe241912f4bef78f Mon Sep 17 00:00:00 2001
From: Jay Klehr 
Date: Sun, 14 Jan 2018 18:07:17 -0700
Subject: [PATCH 7/9] Fixing issues with Db, Validate and Session tests, just
 Date stuff left I believe

---
 library/Zend/Db/Table/Abstract.php     |  2 +-
 library/Zend/Validate/EmailAddress.php |  2 +-
 tests/Zend/Amf/RequestTest.php         |  5 ++---
 tests/Zend/Session/SessionTest.php     | 12 +++++++++---
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/library/Zend/Db/Table/Abstract.php b/library/Zend/Db/Table/Abstract.php
index 66aa60545a..6edcaa9a8b 100644
--- a/library/Zend/Db/Table/Abstract.php
+++ b/library/Zend/Db/Table/Abstract.php
@@ -1304,13 +1304,13 @@ public function find()
         $whereList = array();
         $numberTerms = 0;
         foreach ($args as $keyPosition => $keyValues) {
-            $keyValuesCount = count($keyValues);
             // Coerce the values to an array.
             // Don't simply typecast to array, because the values
             // might be Zend_Db_Expr objects.
             if (!is_array($keyValues)) {
                 $keyValues = array($keyValues);
             }
+            $keyValuesCount = count($keyValues);
             if ($numberTerms == 0) {
                 $numberTerms = $keyValuesCount;
             } else if ($keyValuesCount != $numberTerms) {
diff --git a/library/Zend/Validate/EmailAddress.php b/library/Zend/Validate/EmailAddress.php
index 8bffcaec39..21076e6128 100644
--- a/library/Zend/Validate/EmailAddress.php
+++ b/library/Zend/Validate/EmailAddress.php
@@ -453,7 +453,7 @@ private function _validateMXRecords()
 
         //decode IDN domain name if possible
         if (function_exists('idn_to_ascii')) {
-            $hostname = idn_to_ascii($this->_hostname);
+            $hostname = idn_to_ascii($this->_hostname, 0, INTL_IDNA_VARIANT_UTS46);
         }
 
         $result = getmxrr($hostname, $mxHosts);
diff --git a/tests/Zend/Amf/RequestTest.php b/tests/Zend/Amf/RequestTest.php
index d07ab4045f..c2ed182f92 100644
--- a/tests/Zend/Amf/RequestTest.php
+++ b/tests/Zend/Amf/RequestTest.php
@@ -425,7 +425,7 @@ public function testAmf0MixedArrayParameterDeserializedToNativePhpObject()
         $myRequest = file_get_contents(dirname(__FILE__) .'/Request/mock/mixedArrayAmf0Request.bin');
         // send the mock object request to be deserialized
         $this->_request->initialize($myRequest);
-        // Make sure that no headers where recieved
+        // Make sure that no headers were recieved
         $this->assertEquals(0 , sizeof($this->_request->getAmfHeaders()));
         // Make sure that the message body was set after deserialization
         $this->assertEquals(1, sizeof($this->_request->getAmfBodies()));
@@ -433,7 +433,7 @@ public function testAmf0MixedArrayParameterDeserializedToNativePhpObject()
         $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
         $data = $bodies[0]->getData();
         // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(array_key_exists(1, $data[0]));
+        $this->assertTrue(array_key_exists(1, get_object_vars($data[0])));
         $this->assertEquals('two', $data[0]->two);
     }
 
@@ -666,4 +666,3 @@ public function testAmf0CredentialsInHeader()
 if (PHPUnit_MAIN_METHOD == 'Zend_Amf_RequestTest::main') {
     Zend_Amf_RequestTest::main();
 }
-
diff --git a/tests/Zend/Session/SessionTest.php b/tests/Zend/Session/SessionTest.php
index b59c4a2b18..2d051a047b 100644
--- a/tests/Zend/Session/SessionTest.php
+++ b/tests/Zend/Session/SessionTest.php
@@ -71,7 +71,7 @@ public function __construct($name = NULL, array $data = array(), $dataName = '')
     /**
      * Set up tests environment
      */
-    function setUp()
+    public function setUp()
     {
         // _unitTestEnabled is utilised by other tests to handle session data processing
         // Zend_Session tests should pass with _unitTestEnabled turned off
@@ -85,7 +85,8 @@ function setUp()
      */
     public function tearDown()
     {
-        ini_set('session.save_path', $this->_savePath);
+        session_abort();
+        session_save_path($this->_savePath);
 
         $this->assertSame(
             E_ALL | E_STRICT,
@@ -104,6 +105,9 @@ public function tearDown()
                 return;
             }
         }
+
+        Zend_Session::$_unitTestEnabled = true;
+        Zend_Session::destroy();
     }
 
     /**
@@ -1085,6 +1089,8 @@ public function testInvalidPreexistingSessionIdDoesNotPreventRegenerationOfSid()
         if ( !is_dir($sessionStore) ) @mkdir($sessionStore, 0755, true);
         ini_set('session.save_path', "1;666;" . $sessionStore);
 
+        session_start();
+
         // When using subdirs for session.save_path, the directory structure
         // is your own responsibility...set it up, or else bad things happen
         foreach ( $sessionCharSet as $subdir ) {
@@ -1107,7 +1113,7 @@ public function testInvalidPreexistingSessionIdDoesNotPreventRegenerationOfSid()
 
         // We don't need the session any more, clean it up
         //but we don't to want to destroy it completely, while other tests can start
-        Zend_Session::$_unitTestEnabled = true; 
+        Zend_Session::$_unitTestEnabled = true;
         Zend_Session::destroy();
         foreach ( $sessionCharSet as $subdir ) {
             @rmdir($sessionStore . DIRECTORY_SEPARATOR . $subdir);

From 8ec9c8c2fef4977305681e6aa0152358341022b2 Mon Sep 17 00:00:00 2001
From: Jay Klehr 
Date: Mon, 15 Jan 2018 09:50:47 -0700
Subject: [PATCH 8/9] Moving session_start, branching assertions in
 sunrise/sunset tests

---
 library/Zend/Date/DateObject.php   |   8 +-
 tests/Zend/Date/DateObjectTest.php | 116 ++++++++++++++++++++---------
 tests/Zend/DateTest.php            |  60 +++++++++++----
 tests/Zend/Session/SessionTest.php |   4 +-
 4 files changed, 134 insertions(+), 54 deletions(-)

diff --git a/library/Zend/Date/DateObject.php b/library/Zend/Date/DateObject.php
index 0ec9fce9fc..72cbf45073 100644
--- a/library/Zend/Date/DateObject.php
+++ b/library/Zend/Date/DateObject.php
@@ -313,10 +313,10 @@ protected function date($format, $timestamp = null, $gmt = false)
 
         if (abs($timestamp) <= 0x7FFFFFFF) {
             // See ZF-11992
-            // "o" will sometimes resolve to the previous year (see 
-            // http://php.net/date ; it's part of the ISO 8601 
-            // standard). However, this is not desired, so replacing 
-            // all occurrences of "o" not preceded by a backslash 
+            // "o" will sometimes resolve to the previous year (see
+            // http://php.net/date ; it's part of the ISO 8601
+            // standard). However, this is not desired, so replacing
+            // all occurrences of "o" not preceded by a backslash
             // with "Y"
             $format = preg_replace('/(?assertSame( 9961681, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, true ));
-        $this->assertSame(10010367, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, false));
-        $this->assertSame( 9967006, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true ));
-        $this->assertSame(10005042, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false));
-        $this->assertSame( 9947773, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, true ));
-        $this->assertSame( 9996438, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, false));
-        $this->assertSame( 9953077, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, true ));
-        $this->assertSame( 9991134, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, false));
-        $this->assertSame( 9923795, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, true ));
-        $this->assertSame( 9972422, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, false));
-        $this->assertSame( 9929062, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true ));
-        $this->assertSame( 9967155, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false));
-        $this->assertSame( 9985660, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, true ));
-        $this->assertSame(10034383, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, false));
-        $this->assertSame( 9991022, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true ));
-        $this->assertSame(10029021, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false));
+        // PHP 7.2.0+ uses a newer algorithm for sunrise/sunset calculation apparently.
+        // Seems to be changed in this commit of "timelib":
+        // https://github.com/derickr/timelib/commit/8d0066f7110d4b8bd1a745bc6628c34577c34ba5
+        // Brought into PHP in this commit:
+        // https://github.com/php/php-src/commit/bdd56f31078bf1f34341943603cf6aaa72e0db5c#diff-b1c4e94d91863a5644d2e9402ec633f1L10
+        // (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', '>=')) {
+            $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 ));
+            $this->assertSame(10005077, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false));
+            $this->assertSame( 9947808, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame( 9996412, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame( 9953052, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame( 9991169, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame( 9923830, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame( 9972397, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame( 9929036, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame( 9967190, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame( 9985695, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(10034357, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, false));
+            $this->assertSame( 9990996, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(10029056, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false));
+        } else {
+            $this->assertSame( 9961681, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, true ));
+            $this->assertSame(10010367, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, false));
+            $this->assertSame( 9967006, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true ));
+            $this->assertSame(10005042, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false));
+            $this->assertSame( 9947773, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame( 9996438, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame( 9953077, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame( 9991134, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame( 9923795, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame( 9972422, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame( 9929062, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame( 9967155, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame( 9985660, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(10034383, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, false));
+            $this->assertSame( 9991022, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(10029021, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false));
+        }
 
         $date = new Zend_Date_DateObjectTestHelper(-148309884);
-        $this->assertSame(-148322663, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, true ));
-        $this->assertSame(-148274758, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, false));
-        $this->assertSame(-148318117, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true ));
-        $this->assertSame(-148279304, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false));
-        $this->assertSame(-148336570, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, true ));
-        $this->assertSame(-148288687, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, false));
-        $this->assertSame(-148332046, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, true ));
-        $this->assertSame(-148293211, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, false));
-        $this->assertSame(-148360548, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, true ));
-        $this->assertSame(-148312703, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, false));
-        $this->assertSame(-148356061, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true ));
-        $this->assertSame(-148317189, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false));
-        $this->assertSame(-148298686, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, true ));
-        $this->assertSame(-148250742, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, false));
-        $this->assertSame(-148294101, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true ));
-        $this->assertSame(-148255327, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false));
+        if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
+            $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 ));
+            $this->assertSame(-148279267, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false));
+            $this->assertSame(-148336533, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame(-148288713, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame(-148332072, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame(-148293174, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame(-148360510, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame(-148312728, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame(-148356087, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame(-148317151, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame(-148298649, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(-148250768, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, false));
+            $this->assertSame(-148294127, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(-148255290, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false));
+        } else {
+            $this->assertSame(-148322663, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, true ));
+            $this->assertSame(-148274758, $date->calcSun(array('latitude' =>  38.4, 'longitude' => -29), -0.0145439, false));
+            $this->assertSame(-148318117, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, true ));
+            $this->assertSame(-148279304, $date->calcSun(array('latitude' => -38.4, 'longitude' => -29), -0.0145439, false));
+            $this->assertSame(-148336570, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame(-148288687, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame(-148332046, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, true ));
+            $this->assertSame(-148293211, $date->calcSun(array('latitude' => -38.4, 'longitude' =>  29), -0.0145439, false));
+            $this->assertSame(-148360548, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame(-148312703, $date->calcSun(array('latitude' =>  38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame(-148356061, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, true ));
+            $this->assertSame(-148317189, $date->calcSun(array('latitude' => -38.4, 'longitude' => 129), -0.0145439, false));
+            $this->assertSame(-148298686, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(-148250742, $date->calcSun(array('latitude' =>  38.4, 'longitude' =>-129), -0.0145439, false));
+            $this->assertSame(-148294101, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, true ));
+            $this->assertSame(-148255327, $date->calcSun(array('latitude' => -38.4, 'longitude' =>-129), -0.0145439, false));
+        }
     }
 
     public function testGetDate()
@@ -539,10 +585,10 @@ public function test_getTime()
         $this->assertTrue(($diff < 2), "Zend_Date_DateObject->_getTime() returned a significantly "
             . "different timestamp than expected: $diff seconds");
     }
-    
+
     /**
      * Test for RFC 2822's Obsolete Date and Time (paragraph 4.3)
-     * 
+     *
      * @see ZF-11296
      */
     public function test_obsRfc2822()
@@ -562,7 +608,7 @@ public function testToStringShouldEqualWithAndWithoutPhpFormat()
         $date = new Zend_Date('22.05.2014');
         $date->setTime('12:00');
         $date->setTimezone('America/Los_Angeles');
-    
+
         $this->assertEquals(
             $date->toString(Zend_Date::ATOM),
             $date->toString(DateTime::ATOM, 'php')
diff --git a/tests/Zend/DateTest.php b/tests/Zend/DateTest.php
index 01f27517eb..d72976877d 100644
--- a/tests/Zend/DateTest.php
+++ b/tests/Zend/DateTest.php
@@ -3818,44 +3818,78 @@ public function testSunFunc()
         $result = Zend_Date_Cities::City('vienna');
         $this->assertTrue(is_array($result));
         $result = $date->getSunset($result);
-        $this->assertSame('2002-01-04T20:09:59+05:00', $result->get(Zend_Date::W3C));
+        // 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', '>=')) {
+            $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));
+        }
 
         unset($result);
         $result = Zend_Date_Cities::City('vienna', 'civil');
         $this->assertTrue(is_array($result));
         $result = $date->getSunset($result);
-        $this->assertSame('2002-01-04T20:09:20+05:00', $result->get(Zend_Date::W3C));
+        if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
+            $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));
+        }
 
         unset($result);
         $result = Zend_Date_Cities::City('vienna', 'nautic');
         $this->assertTrue(is_array($result));
         $result = $date->getSunset($result);
-        $this->assertSame('2002-01-04T20:08:34+05:00', $result->get(Zend_Date::W3C));
+        if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
+            $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));
+        }
 
         unset($result);
         $result = Zend_Date_Cities::City('vienna', 'astronomic');
         $this->assertTrue(is_array($result));
         $result = $date->getSunset($result);
-        $this->assertSame('2002-01-04T20:07:49+05:00', $result->get(Zend_Date::W3C));
+        if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
+            $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));
+        }
 
         unset($result);
         $result = Zend_Date_Cities::City('BERLIN');
         $this->assertTrue(is_array($result));
         $result = $date->getSunrise($result);
-        $this->assertSame('2002-01-04T12:21:21+05:00', $result->get(Zend_Date::W3C));
+        if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
+            $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));
+        }
 
         unset($result);
         $result = Zend_Date_Cities::City('London');
         $this->assertTrue(is_array($result));
         $result = $date->getSunInfo($result);
-        $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C ));
-        $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C     ));
-        $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C    ));
-        $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C));
-        $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date::W3C  ));
-        $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date::W3C      ));
-        $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C     ));
-        $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C ));
+        if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
+            $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    ));
+            $this->assertSame('2002-01-04T13:12:40+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C));
+            $this->assertSame('2002-01-04T21:00:32+05:00', $result['sunset']['effective']->get(Zend_Date::W3C  ));
+            $this->assertSame('2002-01-04T20:59:48+05:00', $result['sunset']['civil']->get(Zend_Date::W3C      ));
+            $this->assertSame('2002-01-04T20:58:57+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C     ));
+            $this->assertSame('2002-01-04T20:58:07+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C ));
+        } else {
+            $this->assertSame('2002-01-04T13:10:10+05:00', $result['sunrise']['effective']->get(Zend_Date::W3C ));
+            $this->assertSame('2002-01-04T13:10:54+05:00', $result['sunrise']['civil']->get(Zend_Date::W3C     ));
+            $this->assertSame('2002-01-04T13:11:45+05:00', $result['sunrise']['nautic']->get(Zend_Date::W3C    ));
+            $this->assertSame('2002-01-04T13:12:35+05:00', $result['sunrise']['astronomic']->get(Zend_Date::W3C));
+            $this->assertSame('2002-01-04T21:00:52+05:00', $result['sunset']['effective']->get(Zend_Date::W3C  ));
+            $this->assertSame('2002-01-04T21:00:08+05:00', $result['sunset']['civil']->get(Zend_Date::W3C      ));
+            $this->assertSame('2002-01-04T20:59:18+05:00', $result['sunset']['nautic']->get(Zend_Date::W3C     ));
+            $this->assertSame('2002-01-04T20:58:28+05:00', $result['sunset']['astronomic']->get(Zend_Date::W3C ));
+        }
 
         unset($result);
         $result = array('longitude' => 0);
diff --git a/tests/Zend/Session/SessionTest.php b/tests/Zend/Session/SessionTest.php
index 2d051a047b..1b1f194609 100644
--- a/tests/Zend/Session/SessionTest.php
+++ b/tests/Zend/Session/SessionTest.php
@@ -1089,14 +1089,14 @@ public function testInvalidPreexistingSessionIdDoesNotPreventRegenerationOfSid()
         if ( !is_dir($sessionStore) ) @mkdir($sessionStore, 0755, true);
         ini_set('session.save_path', "1;666;" . $sessionStore);
 
-        session_start();
-
         // When using subdirs for session.save_path, the directory structure
         // is your own responsibility...set it up, or else bad things happen
         foreach ( $sessionCharSet as $subdir ) {
             @mkdir($sessionStore . DIRECTORY_SEPARATOR . $subdir);
         }
 
+        session_start();
+
         // Set session ID to invalid value
         session_id('xxx');
 

From 92af96fba8440c48705e1b09dd55270e596b2cf3 Mon Sep 17 00:00:00 2001
From: Jay Klehr 
Date: Mon, 15 Jan 2018 10:52:59 -0700
Subject: [PATCH 9/9] Fixing php 5.6 failure on this test

---
 tests/Zend/Amf/RequestTest.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/Zend/Amf/RequestTest.php b/tests/Zend/Amf/RequestTest.php
index c2ed182f92..95daacbeaf 100644
--- a/tests/Zend/Amf/RequestTest.php
+++ b/tests/Zend/Amf/RequestTest.php
@@ -433,7 +433,14 @@ public function testAmf0MixedArrayParameterDeserializedToNativePhpObject()
         $this->assertTrue($bodies[0] instanceof Zend_Amf_Value_MessageBody);
         $data = $bodies[0]->getData();
         // Make sure that the string was deserialized properly and check its value
-        $this->assertTrue(array_key_exists(1, get_object_vars($data[0])));
+        // 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', '>=')) {
+            $this->assertTrue(array_key_exists(1, get_object_vars($data[0])));
+        } else {
+            $this->assertTrue(array_key_exists(1, $data[0]));
+        }
         $this->assertEquals('two', $data[0]->two);
     }