Convert foreach to reset/while (tested)

This commit is contained in:
Miles Lott 2001-08-02 08:59:08 +00:00
parent 67eb3c7e99
commit e9635e2082
6 changed files with 59 additions and 21 deletions

View File

@ -86,7 +86,9 @@ class soap_parser
$this->debug("children string = ".$this->message[$pos]["children"]); $this->debug("children string = ".$this->message[$pos]["children"]);
$children = explode("|",$this->message[$pos]["children"]); $children = explode("|",$this->message[$pos]["children"]);
$this->debug("it has ".count($children)." 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"]); //$this->debug("child pos $child_pos: ".$this->message[$child_pos]["name"]);
if($this->message[$child_pos]["eval_str"] != "") if($this->message[$child_pos]["eval_str"] != "")
@ -176,7 +178,9 @@ class soap_parser
$this->message[$pos]["namespace"] = $this->default_namespace; $this->message[$pos]["namespace"] = $this->default_namespace;
} }
// loop through atts, logging ns and type declarations // 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 ns declarations, add to class level array of valid namespaces
if(ereg("xmlns:",$key)) if(ereg("xmlns:",$key))
@ -357,7 +361,9 @@ class soap_parser
function decode_entities($text) 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); $text = str_replace($encoded,$entity,$text);
} }

View File

@ -66,8 +66,9 @@ class soap_server
$header[] = "Connection: Close\r\n"; $header[] = "Connection: Close\r\n";
$header[] = "Content-Type: text/xml; charset=$this->xml_encoding\r\n"; $header[] = "Content-Type: text/xml; charset=$this->xml_encoding\r\n";
$header[] = "Content-Length: ".strlen($payload)."\r\n\r\n"; $header[] = "Content-Length: ".strlen($payload)."\r\n\r\n";
reset($header); @reset($header);
foreach($header as $hdr) while(list($null,$hdr) = @each($header))
/* foreach($header as $hdr) */
{ {
header($hdr); header($hdr);
} }
@ -85,7 +86,8 @@ class soap_server
if(function_exists("getallheaders")) if(function_exists("getallheaders"))
{ {
$this->headers = 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"; $dump .= "$k: $v\r\n";
} }
@ -327,7 +329,9 @@ class soap_server
if(is_array($params)) if(is_array($params))
{ {
$this->debug("entered verify_method() with ".count($params)." parameters"); $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'"); $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)); $this->debug("got correct number of parameters: ".count($sig));
// make array of param types // 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); $p[] = strtolower($param->type);
} }

View File

@ -106,7 +106,9 @@ class soapclient
{ {
$this->debug("got fault"); $this->debug("got fault");
$faultArray = $return->decode(); $faultArray = $return->decode();
foreach($faultArray as $k => $v) @reset($faultArray);
while(list($k,$v) = @each($faultArray))
/* foreach($faultArray as $k => $v) */
{ {
print "$k = $v<br>"; print "$k = $v<br>";
} }

View File

@ -14,7 +14,9 @@ class soapmsg
{ {
global $namespaces; global $namespaces;
$i = count($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++; $namespaces[$v] = "ns".$i++;
} }
@ -28,7 +30,9 @@ class soapmsg
function make_envelope($payload) function make_envelope($payload)
{ {
global $namespaces; 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\""; $ns_string .= " xmlns:$v=\"$k\"";
} }

View File

@ -141,7 +141,9 @@ class soapval
$this->value = array(); $this->value = array();
if(is_array($vals) && count($vals) >= 1) 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"); $this->debug("checking value $k : $v");
// if soapval, add.. // if soapval, add..
@ -194,7 +196,9 @@ class soapval
$this->debug("adding struct '$this->name' with ".count($vals)." vals"); $this->debug("adding struct '$this->name' with ".count($vals)." vals");
if(is_array($vals) && count($vals) >= 1) 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 serialize, if soapval
if(get_class($v) == "soapval") if(get_class($v) == "soapval")
@ -207,7 +211,9 @@ class soapval
{ {
if(is_array($v)) 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") if($a == "0")
{ {
@ -288,7 +294,9 @@ class soapval
} }
if(is_array($soapval->value)) 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); $xml .= $this->serializeval($v);
} }
@ -304,7 +312,9 @@ class soapval
break; break;
case 2: case 2:
// array // 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; $array_types[$array_val->type] = 1;
$xml .= $this->serializeval($array_val); $xml .= $this->serializeval($array_val);
@ -351,7 +361,9 @@ class soapval
{ {
if(is_array($soapval->value)) 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); $return[] = $this->decode($item);
} }
@ -367,7 +379,9 @@ class soapval
{ {
if(is_array($soapval->value)) 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); $return[$item->name] = $this->decode($item);
} }
@ -388,7 +402,9 @@ class soapval
// global $namespaces,$soapTypes,$typemap; // global $namespaces,$soapTypes,$typemap;
global $namespaces,$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)) if(in_array($type,$types))
{ {

View File

@ -208,10 +208,14 @@ class wsdl
function getPortName($operation) 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); $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) if($op == $operation)
{ {