PHP8 change each() to foreach()

This commit is contained in:
Basemaster 2024-08-22 13:18:34 +03:00 committed by GitHub
parent 4886f1e645
commit 75c440c4bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 11 deletions

View File

@ -195,7 +195,8 @@ class Snoopy
$frameurls = $this->_frameurls;
$this->_frameurls = [];
while (list(, $frameurl) = each($frameurls))
//while (list(, $frameurl) = each($frameurls))
foreach ($frameurls as $frameurl)
{
if ($this->_framedepth < $this->maxframes)
{
@ -327,7 +328,8 @@ class Snoopy
$frameurls = $this->_frameurls;
$this->_frameurls = [];
while (list(, $frameurl) = each($frameurls))
//while (list(, $frameurl) = each($frameurls))
foreach ($frameurls as $frameurl)
{
if ($this->_framedepth < $this->maxframes)
{
@ -603,7 +605,8 @@ class Snoopy
// catenate the non-empty matches from the conditional subpattern
while (list($key, $val) = each($links[2]))
//while (list($key, $val) = each($links[2]))
foreach ($links[2] as $key => $val)
{
if (!empty($val))
{
@ -611,7 +614,8 @@ class Snoopy
}
}
while (list($key, $val) = each($links[3]))
//while (list($key, $val) = each($links[3]))
foreach ($links[3] as $key => $val)
{
if (!empty($val))
{
@ -833,7 +837,8 @@ class Snoopy
{
$this->rawheaders = (array) $this->rawheaders;
}
while (list($headerKey, $headerVal) = each($this->rawheaders))
//while (list($headerKey, $headerVal) = each($this->rawheaders))
foreach ($this->rawheaders as $headerKey => $headerVal)
{
$headers .= $headerKey . ": " . $headerVal . "\r\n";
}
@ -1165,11 +1170,13 @@ class Snoopy
{
case "application/x-www-form-urlencoded":
reset($formvars);
while (list($key, $val) = each($formvars))
//while (list($key, $val) = each($formvars))
foreach ($formvars as $key => $val)
{
if (is_array($val) || is_object($val))
{
while (list($cur_key, $cur_val) = each($val))
//while (list($cur_key, $cur_val) = each($val))
foreach ($val as $cur_key => $cur_val)
{
$postdata .= urlencode($key) . "[]=" . urlencode($cur_val) . "&";
}
@ -1185,11 +1192,13 @@ class Snoopy
$this->_mime_boundary = "Snoopy" . md5(uniqid(microtime()));
reset($formvars);
while (list($key, $val) = each($formvars))
//while (list($key, $val) = each($formvars))
foreach ($formvars as $key => $val)
{
if (is_array($val) || is_object($val))
{
while (list($cur_key, $cur_val) = each($val))
//while (list($cur_key, $cur_val) = each($val))
foreach ($val as $cur_key => $cur_val)
{
$postdata .= "--" . $this->_mime_boundary . "\r\n";
$postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
@ -1205,10 +1214,12 @@ class Snoopy
}
reset($formfiles);
while (list($field_name, $file_names) = each($formfiles))
//while (list($field_name, $file_names) = each($formfiles))
foreach ($formfiles as $field_name => $file_name)
{
settype($file_names, "array");
while (list(, $file_name) = each($file_names))
//while (list(, $file_name) = each($file_names))
foreach ($file_names as $file_name)
{
if (!is_readable($file_name))
{