mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Deprecate each()
This commit is contained in:
@@ -25,6 +25,8 @@ echo "Done\n";
|
||||
Warning: each() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
|
||||
Warning: Variable passed to each() is not an array or object in %s on line %d
|
||||
NULL
|
||||
|
||||
|
||||
@@ -7,4 +7,6 @@ each($foo);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
|
||||
Warning: Variable passed to each() is not an array or object in %s on line %d
|
||||
|
||||
@@ -16,6 +16,7 @@ var_dump(each($a));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
bool(false)
|
||||
bool(false)
|
||||
array(4) {
|
||||
|
||||
@@ -12,6 +12,7 @@ var_dump(each($a[1]));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
array(0) {
|
||||
|
||||
@@ -727,6 +727,11 @@ ZEND_FUNCTION(each)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EG(each_deprecation_thrown)) {
|
||||
zend_error(E_DEPRECATED, "The each() function is deprecated. This message will be suppressed on further calls");
|
||||
EG(each_deprecation_thrown) = 1;
|
||||
}
|
||||
|
||||
target_hash = HASH_OF(array);
|
||||
if (!target_hash) {
|
||||
zend_error(E_WARNING,"Variable passed to each() is not an array or object");
|
||||
|
||||
@@ -185,6 +185,8 @@ void init_executor(void) /* {{{ */
|
||||
EG(ht_iterators) = EG(ht_iterators_slots);
|
||||
memset(EG(ht_iterators), 0, sizeof(EG(ht_iterators_slots)));
|
||||
|
||||
EG(each_deprecation_thrown) = 0;
|
||||
|
||||
EG(active) = 1;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -230,6 +230,8 @@ struct _zend_executor_globals {
|
||||
zend_function trampoline;
|
||||
zend_op call_trampoline_op;
|
||||
|
||||
zend_bool each_deprecation_thrown;
|
||||
|
||||
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
|
||||
};
|
||||
|
||||
|
||||
@@ -128,19 +128,18 @@ memory_limit=83886080
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($expected))
|
||||
reset($expected);
|
||||
while ((list($k, $v) = each($expected)) && mysqli_stmt_fetch($stmt)) {
|
||||
if (!empty($expected)) {
|
||||
if ($result !== $v) {
|
||||
printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
|
||||
$offset + 8,
|
||||
$k,
|
||||
gettype($v), $v,
|
||||
gettype($result), $result,
|
||||
$order_by_col,
|
||||
$format, $sql);
|
||||
}
|
||||
foreach ($expected as $k => $v) {
|
||||
if (!mysqli_stmt_fetch($stmt)) {
|
||||
break;
|
||||
}
|
||||
if ($result !== $v) {
|
||||
printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
|
||||
$offset + 8,
|
||||
$k,
|
||||
gettype($v), $v,
|
||||
gettype($result), $result,
|
||||
$order_by_col,
|
||||
$format, $sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,8 @@ if (!$IS_MYSQLND)
|
||||
}
|
||||
reset($fields);
|
||||
foreach ($fields_stmt as $fields_stmt_val) {
|
||||
list(,$fields_val) = each($fields);
|
||||
$fields_val = current($fields);
|
||||
next($fields);
|
||||
unset($fields_stmt_val->max_length);
|
||||
unset($fields_val->max_length);
|
||||
if ($fields_stmt_val != $fields_val) {
|
||||
|
||||
@@ -117,8 +117,10 @@ memory_limit=83886080
|
||||
return false;
|
||||
}
|
||||
|
||||
reset($expected);
|
||||
while ((list($k, $v) = each($expected)) && mysqli_stmt_fetch($stmt)) {
|
||||
foreach ($expected as $k => $v) {
|
||||
if (!mysqli_stmt_fetch($stmt)) {
|
||||
break;
|
||||
}
|
||||
if ($result !== $v) {
|
||||
printf("[%03d] Row %d - expecting %s/%s got %s/%s [%s] with %s - %s.\n",
|
||||
$offset + 8,
|
||||
@@ -269,9 +271,10 @@ memory_limit=83886080
|
||||
break;
|
||||
}
|
||||
|
||||
reset($values);
|
||||
while (mysqli_stmt_fetch($stmt)) {
|
||||
list($exp_trend, $exp_targetport) = each($values);
|
||||
foreach ($values as $exp_trend => $exp_targetport) {
|
||||
if (!mysqli_stmt_fetch($stmt)) {
|
||||
break;
|
||||
}
|
||||
if ($targetport != $exp_targetport) {
|
||||
printf("[306] Values fetched from MySQL seem to be wrong, check manually\n");
|
||||
printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format);
|
||||
@@ -308,9 +311,10 @@ memory_limit=83886080
|
||||
break;
|
||||
}
|
||||
|
||||
reset($values);
|
||||
while ($stmt->fetch()) {
|
||||
list($exp_trend, $exp_targetport) = each($values);
|
||||
foreach ($values as $exp_trend => $exp_targetport) {
|
||||
if (!$stmt->fetch()) {
|
||||
break;
|
||||
}
|
||||
if ($targetport != $exp_targetport) {
|
||||
printf("[312] Values fetched from MySQL seem to be wrong, check manually\n");
|
||||
printf("%s/%s - %s/%s - '%s'\n", $trend, $exp_trend, $targetport, $exp_targetport, $format);
|
||||
@@ -334,4 +338,4 @@ memory_limit=83886080
|
||||
require_once("clean_table.inc");
|
||||
?>
|
||||
--EXPECTF--
|
||||
done!
|
||||
done!
|
||||
|
||||
@@ -7,8 +7,8 @@ $array = range(1, 10);
|
||||
|
||||
preg_grep('/asdf/', $array);
|
||||
|
||||
while (list($x) = each($array)) {
|
||||
print $x;
|
||||
foreach ($array as $k => $v) {
|
||||
print $k;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Binary file not shown.
@@ -46,6 +46,8 @@ array(4) {
|
||||
}
|
||||
|
||||
-- Initial position: --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
int(1)
|
||||
@@ -71,4 +73,4 @@ array(4) {
|
||||
|
||||
-- Passed the end of array: --
|
||||
bool(false)
|
||||
Done
|
||||
Done
|
||||
|
||||
@@ -101,6 +101,8 @@ echo "Done";
|
||||
|
||||
-- Iteration 1 --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
|
||||
Warning: Variable passed to each() is not an array or object in %s on line %d
|
||||
NULL
|
||||
|
||||
|
||||
@@ -122,6 +122,8 @@ echo "Done";
|
||||
*** Testing each() : usage variations ***
|
||||
|
||||
-- Iteration 1: int data --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
int(0)
|
||||
@@ -245,4 +247,4 @@ array(4) {
|
||||
["key"]=>
|
||||
int(0)
|
||||
}
|
||||
Done
|
||||
Done
|
||||
|
||||
@@ -108,6 +108,8 @@ echo "Done";
|
||||
*** Testing each() : usage variations ***
|
||||
|
||||
-- Iteration 1: int data --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
string(4) "zero"
|
||||
@@ -250,4 +252,4 @@ array(4) {
|
||||
["key"]=>
|
||||
string(0) ""
|
||||
}
|
||||
Done
|
||||
Done
|
||||
|
||||
@@ -35,6 +35,8 @@ echo "Done";
|
||||
|
||||
-- Array made up of referenced variables: --
|
||||
-- Call each until at the end of the array: --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
string(3) "foo"
|
||||
|
||||
@@ -37,6 +37,8 @@ echo "Done";
|
||||
*** Testing each() : usage variations ***
|
||||
|
||||
-- Pass each() a two-dimensional array --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
string(4) "zero"
|
||||
@@ -93,4 +95,4 @@ array(4) {
|
||||
["key"]=>
|
||||
int(0)
|
||||
}
|
||||
Done
|
||||
Done
|
||||
|
||||
@@ -35,6 +35,8 @@ echo "Done";
|
||||
0 => zero
|
||||
|
||||
-- Call to each(): --
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
array(4) {
|
||||
[1]=>
|
||||
string(4) "zero"
|
||||
@@ -48,4 +50,4 @@ array(4) {
|
||||
|
||||
-- New position: --
|
||||
1 => one
|
||||
Done
|
||||
Done
|
||||
|
||||
@@ -35,7 +35,7 @@ function startElement($parser, $name, $attribs)
|
||||
{
|
||||
print '{'.$name;
|
||||
if (sizeof($attribs)) {
|
||||
while (list($k, $v) = each($attribs)) {
|
||||
foreach ($attribs as $k => $v) {
|
||||
print " $k=\"$v\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class myclass
|
||||
{
|
||||
print '{'.$name;
|
||||
if (sizeof($attribs)) {
|
||||
while (list($k, $v) = each($attribs)) {
|
||||
foreach ($attribs as $k => $v) {
|
||||
print " $k=\"$v\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class myclass
|
||||
{
|
||||
print '{'.$name;
|
||||
if (sizeof($attribs)) {
|
||||
while (list($k, $v) = each($attribs)) {
|
||||
foreach ($attribs as $k => $v) {
|
||||
print " $k=\"$v\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ function start_element($xp, $elem, $attribs)
|
||||
{
|
||||
print "<$elem";
|
||||
if (sizeof($attribs)) {
|
||||
while (list($k, $v) = each($attribs)) {
|
||||
foreach ($attribs as $k => $v) {
|
||||
print " $k=\"$v\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ $start_element = function ($xp, $elem, $attribs)
|
||||
{
|
||||
print "<$elem";
|
||||
if (sizeof($attribs)) {
|
||||
while (list($k, $v) = each($attribs)) {
|
||||
foreach ($attribs as $k => $v) {
|
||||
print " $k=\"$v\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2415,7 +2415,7 @@ function compute_summary()
|
||||
$sum_results['SKIPPED'] += $ignored_by_ext;
|
||||
$percent_results = array();
|
||||
|
||||
while (list($v, $n) = each($sum_results)) {
|
||||
foreach ($sum_results as $v => $n) {
|
||||
$percent_results[$v] = (100.0 * $n) / $n_total;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,7 +901,7 @@ class testHarness {
|
||||
}
|
||||
$sum_results['SKIPPED'] += $this->ignored_by_ext;
|
||||
$percent_results = array();
|
||||
while (list($v,$n) = each($sum_results)) {
|
||||
foreach ($sum_results as $v => $n) {
|
||||
$percent_results[$v] = (100.0 * $n) / $n_total;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,9 @@ class ai implements Iterator {
|
||||
}
|
||||
|
||||
function next() {
|
||||
list($this->key, $this->current) = each($this->array);
|
||||
// list($key, $current) = each($this->array);
|
||||
// $this->key = $key;
|
||||
// $this->current = $current;
|
||||
$this->key = key($this->array);
|
||||
$this->current = current($this->array);
|
||||
next($this->array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,10 @@ while(list(,$o) = each($arrayOuter)){
|
||||
reset($arrayOuter);
|
||||
reset($arrayInner);
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
Correct - with inner loop reset.
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
inloop 0 for key1
|
||||
inloop 1 for key1
|
||||
inloop 0 for key2
|
||||
|
||||
@@ -9,5 +9,7 @@ while (list($key, $val) = each($arr)) {
|
||||
echo urlencode($key), ' => ', urlencode($val), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
--EXPECTF--
|
||||
|
||||
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in %s on line %d
|
||||
7: foo%00bar => foo%00bar
|
||||
|
||||
Reference in New Issue
Block a user