Ver Fonte

removed usages of depricated each()

George Appleton há 7 anos atrás
pai
commit
3e9b26c748

+ 3 - 3
demos/Zend/Mobile/Push/ApnsFeedback.php

@@ -3,7 +3,7 @@ require_once 'Zend/Mobile/Push/Apns.php';
 
 $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 @@ try {
     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();

+ 2 - 2
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();
 ]]></programlisting>
-        
+
     </sect2>
 
     <sect2 id="zend.mobile.push.apns.message">

+ 1 - 1
library/Zend/Cache/Backend.php

@@ -76,7 +76,7 @@ class Zend_Cache_Backend
     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");
             }

+ 3 - 3
library/Zend/Config/Yaml.php

@@ -202,7 +202,7 @@ class Zend_Config_Yaml extends Zend_Config
                 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 @@ class Zend_Config_Yaml extends Zend_Config
             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,7 +289,7 @@ class Zend_Config_Yaml extends Zend_Config
     {
         $config   = array();
         $inIndent = false;
-        while (list($n, $line) = each($lines)) {
+        foreach ($line as $n => $line) {
             $lineno = $n + 1;
 
             $line = rtrim(preg_replace("/#.*$/", "", $line));

+ 1 - 1
library/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php

@@ -88,7 +88,7 @@ class Zend_Http_UserAgent_Features_Adapter_TeraWurfl implements Zend_Http_UserAg
             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');

+ 2 - 2
library/Zend/XmlRpc/Value.php

@@ -486,13 +486,13 @@ abstract class Zend_XmlRpc_Value
      */
     protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value)
     {
-        list($type, $value) = each($xml);
+        [$type, $value] = [key($xml), current($xml)];
 
         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);
+                [$type, $value] = [key($namespaceXml), current($namespaceXml)];
                 if ($type !== null) {
                     $type = $namespaceName . ':' . $type;
                     break;

+ 2 - 10
tests/Zend/XmlRpc/RequestTest.php

@@ -287,18 +287,10 @@ class Zend_XmlRpc_RequestTest extends PHPUnit_Framework_TestCase
         }
 
         $result = $sx->xpath('//methodName');
-        $count = 0;
-        while (list( , $node) = each($result)) {
-            ++$count;
-        }
-        $this->assertEquals(1, $count, $xml);
+        $this->assertEquals(1, count($result), $xml);
 
         $result = $sx->xpath('//params');
-        $count = 0;
-        while (list( , $node) = each($result)) {
-            ++$count;
-        }
-        $this->assertEquals(1, $count, $xml);
+        $this->assertEquals(1, count($result), $xml);
 
         try {
             $methodName = (string) $sx->methodName;

+ 2 - 2
tests/runalltests.php

@@ -58,7 +58,7 @@ sort($files);
 $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;
@@ -68,7 +68,7 @@ while(list(, $file)=each($files)) {
     system($PHPUNIT . ' --stderr -d memory_limit=-1 -d error_reporting=E_ALL\&E_STRICT -d display_errors=1 ' . escapeshellarg($file), $c_result);
     echo PHP_EOL;
     echo "Finished executing {$file}" . PHP_EOL;
-    
+
     if ($c_result) {
         echo PHP_EOL . "Result of $file is $c_result" . PHP_EOL . PHP_EOL;
         $result = $c_result;