Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
while()each() becomes foreach()
Browse files Browse the repository at this point in the history
php 7.2 compat.
  • Loading branch information
gburton committed Feb 12, 2018
1 parent e081782 commit 3788401
Show file tree
Hide file tree
Showing 50 changed files with 156 additions and 269 deletions.
3 changes: 1 addition & 2 deletions account_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set global_product_notifications = '" . (int)$product_global . "' where customers_info_id = '" . (int)$customer_id . "'");
} elseif (sizeof($products) > 0) {
$products_parsed = array();
reset($products);
while (list(, $value) = each($products)) {
foreach($products as $value) {
if (is_numeric($value)) {
$products_parsed[] = $value;
}
Expand Down
7 changes: 3 additions & 4 deletions admin/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

$tables_query = tep_db_query('show tables');
while ($tables = tep_db_fetch_array($tables_query)) {
list(,$table) = each($tables);
$table = reset($tables);

$schema = 'drop table if exists ' . $table . ';' . "\n" .
'create table ' . $table . ' (' . "\n";
Expand Down Expand Up @@ -80,7 +80,7 @@
$index[$kname]['columns'][] = $keys['Column_name'];
}

while (list($kname, $info) = each($index)) {
foreach ($index as $kname => $info) {
$schema .= ',' . "\n";

$columns = implode($info['columns'], ', ');
Expand All @@ -105,8 +105,7 @@
while ($rows = tep_db_fetch_array($rows_query)) {
$schema = 'insert into ' . $table . ' (' . implode(', ', $table_list) . ') values (';

reset($table_list);
while (list(,$i) = each($table_list)) {
foreach ($table_list as $i) {
if (!isset($rows[$i])) {
$schema .= 'NULL, ';
} elseif (tep_not_null($rows[$i])) {
Expand Down
6 changes: 2 additions & 4 deletions admin/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
}
}

reset($products);
while (list($key, $value) = each($products)) {
foreach ($products as $key => $value) {
$category_ids = '';

for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {
Expand All @@ -137,8 +136,7 @@
tep_remove_category($categories[$i]['id']);
}

reset($products_delete);
while (list($key) = each($products_delete)) {
foreach ($products_delete as $key) {
tep_remove_product($key);
}
}
Expand Down
2 changes: 1 addition & 1 deletion admin/ext/modules/payment/sofortueberweisung/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function tep_create_random_value($length, $type = 'mixed') {

$get_parameter = '';
$x = 0;
while(list($key,$value) = each($parameter)) {
foreach($parameter as $key => $value) {
if (empty($value)) continue;
if ($x > 0) $get_parameter .= "&";
$get_parameter .= $key . "=" . urlencode($value);
Expand Down
14 changes: 5 additions & 9 deletions admin/includes/classes/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ function __construct($headers = '') {

$this->headers[] = 'MIME-Version: 1.0';

reset($headers);
while (list(,$value) = each($headers)) {
foreach($headers as $value) {
if (tep_not_null($value)) {
$this->headers[] = $value;
}
Expand Down Expand Up @@ -113,7 +112,7 @@ function get_file($filename) {

function find_html_images($images_dir) {
// Build the list of image extensions
while (list($key, ) = each($this->image_types)) {
foreach(array_keys($this->image_types) as $key) {
$extensions[] = $key;
}

Expand Down Expand Up @@ -322,15 +321,13 @@ function build_message($params = '') {
if ($params == '') $params = array();

if (count($params) > 0) {
reset($params);
while(list($key, $value) = each($params)) {
foreach($params as $key => $value) {
$this->build_params[$key] = $value;
}
}

if (tep_not_null($this->html_images)) {
reset($this->html_images);
while (list(,$value) = each($this->html_images)) {
foreach($this->html_images as $value) {
$this->html = str_replace($value['name'], 'cid:' . $value['cid'], $this->html);
}
}
Expand Down Expand Up @@ -453,8 +450,7 @@ function build_message($params = '') {
$output = $message->encode();
$this->output = $output['body'];

reset($output['headers']);
while (list($key, $value) = each($output['headers'])) {
foreach($output['headers'] as $key => $value) {
$headers[] = $key . ': ' . $value;
}

Expand Down
3 changes: 1 addition & 2 deletions admin/includes/classes/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ function get_browser_language() {
$this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE'));

for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) {
reset($this->languages);
while (list($key, $value) = each($this->languages)) {
foreach($this->languages as $key => $value) {
if (preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/i', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {
$this->language = $this->catalog_languages[$key];
break 2;
Expand Down
8 changes: 3 additions & 5 deletions admin/includes/classes/mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ function __construct($body, $params = '') {
$this->lf = "\n";
}

reset($params);
while (list($key, $value) = each($params)) {
foreach($params as $key => $value) {
switch ($key) {
case 'content_type':
$headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
Expand Down Expand Up @@ -126,8 +125,7 @@ function encode() {
$_subparts = $this->_subparts[$i];
$tmp = $_subparts->encode();

reset($tmp['headers']);
while (list($key, $value) = each($tmp['headers'])) {
foreach($tmp['headers'] as $key => $value) {
$headers[] = $key . ': ' . $value;
}

Expand Down Expand Up @@ -214,7 +212,7 @@ function _quotedPrintableEncode($input , $line_max = 76) {
$escape = '=';
$output = '';

while (list(, $line) = each($lines)) {
foreach($lines as $line) {
$linlen = strlen($line);
$newline = '';

Expand Down
3 changes: 1 addition & 2 deletions admin/includes/classes/object_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ function __construct($object_array) {
}

function objectInfo($object_array) {
reset($object_array);
while (list($key, $value) = each($object_array)) {
foreach($object_array as $key => $value) {
$this->$key = tep_db_prepare_input($value);
}
}
Expand Down
Loading

0 comments on commit 3788401

Please sign in to comment.