php-src/Zend/tests/bug71266.phpt
Nikita Popov dcc8463ae5 Deprecate IAP functions on objects
Deprecate use of key(), current(), next(), prev(), reset() and
end() on objects. Cast the object to array first.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:28:33 +02:00

25 lines
452 B
PHP

--TEST--
Bug #71266 (Missing separation of properties HT in foreach etc)
--FILE--
<?php
$one = 1;
$two = 2;
$arr = ['foo' => $one, 'bar' => $two];
$obj = (object) $arr;
foreach ($obj as $val) {
var_dump($val);
$obj->bar = 42;
}
$arr = ['foo' => $one, 'bar' => $two];
$obj = (object) $arr;
next($obj);
var_dump(current($arr));
?>
--EXPECTF--
int(1)
int(42)
Deprecated: next(): Calling next() on an object is deprecated in %s on line %d
int(1)