diff --git a/demos/Zend/Mobile/Push/ApnsFeedback.php b/demos/Zend/Mobile/Push/ApnsFeedback.php index e2b5489eb0..345bb49e25 100644 --- a/demos/Zend/Mobile/Push/ApnsFeedback.php +++ b/demos/Zend/Mobile/Push/ApnsFeedback.php @@ -15,7 +15,7 @@ } $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..1b36fb5f44 100644 --- a/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml +++ b/documentation/manual/en/module_specs/Zend_Mobile_Push-Apns.xml @@ -152,7 +152,7 @@ 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 9a78057122..898db93a5e 100644 --- a/library/Zend/Cache/Backend.php +++ b/library/Zend/Cache/Backend.php @@ -61,7 +61,7 @@ class Zend_Cache_Backend */ public function __construct(array $options = array()) { - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $this->setOption($name, $value); } } @@ -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/Cache/Core.php b/library/Zend/Cache/Core.php index d649a70aff..4e7f028270 100644 --- a/library/Zend/Cache/Core.php +++ b/library/Zend/Cache/Core.php @@ -143,7 +143,7 @@ public function __construct($options = array()) Zend_Cache::throwException("Options passed were not an array" . " or Zend_Config instance."); } - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $this->setOption($name, $value); } $this->_loggerSanity(); @@ -158,7 +158,7 @@ public function __construct($options = array()) public function setConfig(Zend_Config $config) { $options = $config->toArray(); - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $this->setOption($name, $value); } return $this; diff --git a/library/Zend/Cache/Frontend/Class.php b/library/Zend/Cache/Frontend/Class.php index 8ac98c24ac..a232143119 100644 --- a/library/Zend/Cache/Frontend/Class.php +++ b/library/Zend/Cache/Frontend/Class.php @@ -106,7 +106,7 @@ class Zend_Cache_Frontend_Class extends Zend_Cache_Core */ public function __construct(array $options = array()) { - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $this->setOption($name, $value); } if ($this->_specificOptions['cached_entity'] === null) { diff --git a/library/Zend/Cache/Frontend/File.php b/library/Zend/Cache/Frontend/File.php index 9ff13b1b7e..911132bb10 100644 --- a/library/Zend/Cache/Frontend/File.php +++ b/library/Zend/Cache/Frontend/File.php @@ -88,7 +88,7 @@ class Zend_Cache_Frontend_File extends Zend_Cache_Core */ public function __construct(array $options = array()) { - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $this->setOption($name, $value); } if (!isset($this->_specificOptions['master_files'])) { diff --git a/library/Zend/Cache/Frontend/Function.php b/library/Zend/Cache/Frontend/Function.php index 6e794e99e9..ec2f4161cc 100644 --- a/library/Zend/Cache/Frontend/Function.php +++ b/library/Zend/Cache/Frontend/Function.php @@ -63,7 +63,7 @@ class Zend_Cache_Frontend_Function extends Zend_Cache_Core */ public function __construct(array $options = array()) { - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $this->setOption($name, $value); } $this->setOption('automatic_serialization', true); diff --git a/library/Zend/Cache/Frontend/Page.php b/library/Zend/Cache/Frontend/Page.php index e6ba5f2809..03442fc44e 100644 --- a/library/Zend/Cache/Frontend/Page.php +++ b/library/Zend/Cache/Frontend/Page.php @@ -129,7 +129,7 @@ class Zend_Cache_Frontend_Page extends Zend_Cache_Core */ public function __construct(array $options = array()) { - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { $name = strtolower($name); switch ($name) { case 'regexps': diff --git a/library/Zend/Config/Yaml.php b/library/Zend/Config/Yaml.php index 1dc97aa65f..8e56599cca 100755 --- a/library/Zend/Config/Yaml.php +++ b/library/Zend/Config/Yaml.php @@ -289,7 +289,7 @@ protected static function _decodeYaml($currentIndent, &$lines) { $config = array(); $inIndent = false; - while (list($n, $line) = each($lines)) { + foreach ($lines as $n => $line) { $lineno = $n + 1; $line = rtrim(preg_replace("/#.*$/", "", $line)); diff --git a/library/Zend/Db/Table/Abstract.php b/library/Zend/Db/Table/Abstract.php index 3c10da5354..41932af335 100644 --- a/library/Zend/Db/Table/Abstract.php +++ b/library/Zend/Db/Table/Abstract.php @@ -789,7 +789,7 @@ protected function _setupTableName() */ protected function _setupMetadata() { - if ($this->metadataCacheInClass() && (count($this->_metadata) > 0)) { + if ($this->metadataCacheInClass() && (is_array($this->_metadata) && count($this->_metadata) > 0)) { return true; } diff --git a/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php b/library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php index 9ec1fa5a57..1b37226266 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/Service/DeveloperGarden/Client/ClientAbstract.php b/library/Zend/Service/DeveloperGarden/Client/ClientAbstract.php index 6bc4355a4c..530f4b685e 100644 --- a/library/Zend/Service/DeveloperGarden/Client/ClientAbstract.php +++ b/library/Zend/Service/DeveloperGarden/Client/ClientAbstract.php @@ -135,7 +135,7 @@ public function __construct(array $options = array()) { $this->_credential = new Zend_Service_DeveloperGarden_Credential(); - while (list($name, $value) = each($options)) { + foreach ($options as $name => $value) { switch (ucfirst($name)) { case 'Username' : $this->_credential->setUsername($value); diff --git a/library/Zend/XmlRpc/Value.php b/library/Zend/XmlRpc/Value.php index 08ddf24907..a1432c6f15 100644 --- a/library/Zend/XmlRpc/Value.php +++ b/library/Zend/XmlRpc/Value.php @@ -486,13 +486,19 @@ protected static function _createSimpleXMLElement(&$xml) */ protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value) { - list($type, $value) = each($xml); + // hack to work around each() deprecation in php 7.2 + $type = key($xml); + $value = current($xml); + next($xml); // finally, advance cursor similar to each() if (!$type and $value === null) { $namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions'); foreach ($namespaces as $namespaceName => $namespaceUri) { $namespaceXml = $xml->children($namespaceUri); - list($type, $value) = each($namespaceXml); + // hack to work around each() deprecation in php 7.2 + $type = key($namespaceXml); + $value = current($namespaceXml); + next($namespaceXml); // finally, advance cursor similar to each() if ($type !== null) { $type = $namespaceName . ':' . $type; break; diff --git a/tests/Zend/Service/Technorati/TechnoratiTest.php b/tests/Zend/Service/Technorati/TechnoratiTest.php index 2ccf31e17e..82aa22a35e 100644 --- a/tests/Zend/Service/Technorati/TechnoratiTest.php +++ b/tests/Zend/Service/Technorati/TechnoratiTest.php @@ -567,7 +567,11 @@ private function _testOption($validOptions, $xmlFile, $callbackMethod, $callback { $technorati = $this->_setResponseFromFile($xmlFile); foreach ($validOptions as $pair) { - list($option, $value) = each($pair); + // deprecated; list($option, $value) = each($pair); + // hack to work around each() deprecation in php 7.2 + $option = key($pair); + $value = current($pair); + next($pair); // finally, advance cursor similar to each() $options = is_array($callbackRequiredOptions) ? array_merge($callbackRequiredOptions, array($pair)) : array($pair); @@ -593,7 +597,11 @@ private function _testThrowsExceptionWithInvalidOption($invalidOptions, $xmlFile { $technorati = $this->_setResponseFromFile($xmlFile); foreach ($invalidOptions as $pair) { - list($option, $value) = each($pair); + // deprecated; list($option, $value) = each($pair); + // hack to work around each() deprecation in php 7.2 + $option = key($pair); + $value = current($pair); + next($pair); // finally, advance cursor similar to each() $options = is_array($callbackRequiredOptions) ? array_merge($callbackRequiredOptions, array($pair)) : array($pair); diff --git a/tests/Zend/XmlRpc/RequestTest.php b/tests/Zend/XmlRpc/RequestTest.php index 7596d6230a..df7abb5898 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); diff --git a/tests/runalltests.php b/tests/runalltests.php index 7545998b1f..7a1e64ea9b 100755 --- a/tests/runalltests.php +++ b/tests/runalltests.php @@ -55,7 +55,7 @@ $result = 0; // run through phpunit -while(list(, $file)=each($files)) { +foreach ($files as $file) { if ($_SERVER['TRAVIS_PHP_VERSION'] == 'hhvm' && $file == 'Zend/CodeGenerator/AllTests.php') { echo "Skipping $file on HHVM" . PHP_EOL; //gets stuck on the HHVM continue;