From e9635e208282b04d9b38df44092704e775442838 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Thu, 2 Aug 2001 08:59:08 +0000 Subject: [PATCH] Convert foreach to reset/while (tested) --- phpgwapi/inc/class.soap_parser.inc.php | 12 +++++++--- phpgwapi/inc/class.soap_server.inc.php | 16 +++++++++---- phpgwapi/inc/class.soapclient.inc.php | 4 +++- phpgwapi/inc/class.soapmsg.inc.php | 8 +++++-- phpgwapi/inc/class.soapval.inc.php | 32 +++++++++++++++++++------- phpgwapi/inc/class.wsdl.inc.php | 8 +++++-- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/phpgwapi/inc/class.soap_parser.inc.php b/phpgwapi/inc/class.soap_parser.inc.php index 5361c32b3a..7f22dd35fd 100644 --- a/phpgwapi/inc/class.soap_parser.inc.php +++ b/phpgwapi/inc/class.soap_parser.inc.php @@ -86,7 +86,9 @@ class soap_parser $this->debug("children string = ".$this->message[$pos]["children"]); $children = explode("|",$this->message[$pos]["children"]); $this->debug("it has ".count($children)." children"); - foreach($children as $c => $child_pos) + @reset($children); + while(list($c,$child_pos) = @each($children)) + /* foreach($children as $c => $child_pos) */ { //$this->debug("child pos $child_pos: ".$this->message[$child_pos]["name"]); if($this->message[$child_pos]["eval_str"] != "") @@ -176,7 +178,9 @@ class soap_parser $this->message[$pos]["namespace"] = $this->default_namespace; } // loop through atts, logging ns and type declarations - foreach($attrs as $key => $value) + @reset($attrs); + while (list($key,$value) = @each($attrs)) + /* foreach($attrs as $key => $value) */ { // if ns declarations, add to class level array of valid namespaces if(ereg("xmlns:",$key)) @@ -357,7 +361,9 @@ class soap_parser function decode_entities($text) { - foreach($this->entities as $entity => $encoded) + @reset($this->entities); + while(list($entity,$encoded) = @each($this->entities)) + /* foreach($this->entities as $entity => $encoded) */ { $text = str_replace($encoded,$entity,$text); } diff --git a/phpgwapi/inc/class.soap_server.inc.php b/phpgwapi/inc/class.soap_server.inc.php index 9b2050857e..be00f5d009 100644 --- a/phpgwapi/inc/class.soap_server.inc.php +++ b/phpgwapi/inc/class.soap_server.inc.php @@ -66,8 +66,9 @@ class soap_server $header[] = "Connection: Close\r\n"; $header[] = "Content-Type: text/xml; charset=$this->xml_encoding\r\n"; $header[] = "Content-Length: ".strlen($payload)."\r\n\r\n"; - reset($header); - foreach($header as $hdr) + @reset($header); + while(list($null,$hdr) = @each($header)) + /* foreach($header as $hdr) */ { header($hdr); } @@ -85,7 +86,8 @@ class soap_server if(function_exists("getallheaders")) { $this->headers = getallheaders(); - foreach($this->headers as $k=>$v) + while(list($k,$v) = @each($this->headers)) + /* foreach($this->headers as $k=>$v) */ { $dump .= "$k: $v\r\n"; } @@ -327,7 +329,9 @@ class soap_server if(is_array($params)) { $this->debug("entered verify_method() with ".count($params)." parameters"); - foreach($params as $v) + @reset($params); + while(list($null,$v) = @each($params)) + /* foreach($params as $v) */ { $this->debug("param '$v->name' of type '$v->type'"); } @@ -336,7 +340,9 @@ class soap_server { $this->debug("got correct number of parameters: ".count($sig)); // make array of param types - foreach($params as $param) + @reset($params); + while(list($null,$param) = @each($params)) + /* foreach($params as $param) */ { $p[] = strtolower($param->type); } diff --git a/phpgwapi/inc/class.soapclient.inc.php b/phpgwapi/inc/class.soapclient.inc.php index 4425915307..13d1990ead 100644 --- a/phpgwapi/inc/class.soapclient.inc.php +++ b/phpgwapi/inc/class.soapclient.inc.php @@ -106,7 +106,9 @@ class soapclient { $this->debug("got fault"); $faultArray = $return->decode(); - foreach($faultArray as $k => $v) + @reset($faultArray); + while(list($k,$v) = @each($faultArray)) + /* foreach($faultArray as $k => $v) */ { print "$k = $v
"; } diff --git a/phpgwapi/inc/class.soapmsg.inc.php b/phpgwapi/inc/class.soapmsg.inc.php index c7c5212ce6..52af8f1c29 100644 --- a/phpgwapi/inc/class.soapmsg.inc.php +++ b/phpgwapi/inc/class.soapmsg.inc.php @@ -14,7 +14,9 @@ class soapmsg { global $namespaces; $i = count($namespaces); - foreach($new_namespaces as $v) + @reset($new_namespaces); + while(list($null,$v) = @each($new_namespaces)) + /* foreach($new_namespaces as $v) */ { $namespaces[$v] = "ns".$i++; } @@ -28,7 +30,9 @@ class soapmsg function make_envelope($payload) { global $namespaces; - foreach($namespaces as $k => $v) + @reset($namespaces); + while(list($k,$v) = @each($namespaces)) + /* foreach($namespaces as $k => $v) */ { $ns_string .= " xmlns:$v=\"$k\""; } diff --git a/phpgwapi/inc/class.soapval.inc.php b/phpgwapi/inc/class.soapval.inc.php index 175453c111..dbf0442aec 100644 --- a/phpgwapi/inc/class.soapval.inc.php +++ b/phpgwapi/inc/class.soapval.inc.php @@ -141,7 +141,9 @@ class soapval $this->value = array(); if(is_array($vals) && count($vals) >= 1) { - foreach($vals as $k => $v) + @reset($vals); + while(list($k,$v) = @each($vals)) + /* foreach($vals as $k => $v) */ { $this->debug("checking value $k : $v"); // if soapval, add.. @@ -194,7 +196,9 @@ class soapval $this->debug("adding struct '$this->name' with ".count($vals)." vals"); if(is_array($vals) && count($vals) >= 1) { - foreach($vals as $k => $v) + @reset($vals); + while(list($k,$v) = @each($vals)) + /* foreach($vals as $k => $v) */ { // if serialize, if soapval if(get_class($v) == "soapval") @@ -207,7 +211,9 @@ class soapval { if(is_array($v)) { - foreach($v as $a => $b) + @reset($v); + while(list($a,$b) = @each($v)) + /* foreach($v as $a => $b) */ { if($a == "0") { @@ -288,7 +294,9 @@ class soapval } if(is_array($soapval->value)) { - foreach($soapval->value as $k => $v) + @reset($soapval->value); + while(list($k,$v) = @each($soapval->value)) + /* foreach($soapval->value as $k => $v) */ { $xml .= $this->serializeval($v); } @@ -304,7 +312,9 @@ class soapval break; case 2: // array - foreach($soapval->value as $array_val) + @reset($soapval->value); + while(list($null,$array_val) = @each($soapval->value)) + /* foreach($soapval->value as $array_val) */ { $array_types[$array_val->type] = 1; $xml .= $this->serializeval($array_val); @@ -351,7 +361,9 @@ class soapval { if(is_array($soapval->value)) { - foreach($soapval->value as $item) + @reset($soapval->value); + while(list($null,$item) = @each($soapval->value)) + /* foreach($soapval->value as $item) */ { $return[] = $this->decode($item); } @@ -367,7 +379,9 @@ class soapval { if(is_array($soapval->value)) { - foreach($soapval->value as $item) + @reset($soapval->value); + while(list($null,$item) = @each($soapval->value)) + /* foreach($soapval->value as $item) */ { $return[$item->name] = $this->decode($item); } @@ -388,7 +402,9 @@ class soapval // global $namespaces,$soapTypes,$typemap; global $namespaces,$typemap; - foreach($typemap as $namespace => $types) + @reset($typemap); + while(list($namespace,$types) = @each($typemap)) + /* foreach($typemap as $namespace => $types) */ { if(in_array($type,$types)) { diff --git a/phpgwapi/inc/class.wsdl.inc.php b/phpgwapi/inc/class.wsdl.inc.php index 7a54739a42..aee922e3c5 100644 --- a/phpgwapi/inc/class.wsdl.inc.php +++ b/phpgwapi/inc/class.wsdl.inc.php @@ -208,10 +208,14 @@ class wsdl function getPortName($operation) { - foreach($this->ports as $port => $portAttrs) + @reset($this->ports); + while(list($port,$portAttrs) = @each($this->ports)); + /* foreach($this->ports as $port => $portAttrs) */ { $binding = substr($portAttrs["binding"],4); - foreach($this->bindings[$binding]["operations"] as $op => $opAttrs) + @reset($this->bindings[$binding]["operations"]); + while(list($op,$opAttrs) = @each($this->bindings[$binding]["operations"])) + /* foreach($this->bindings[$binding]["operations"] as $op => $opAttrs) */ { if($op == $operation) {