Closed
Description
Description
The following code:
$array = [
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
new stdClass(),
];
foreach ($array as $key => &$value) {
unset($array[$key]);
$array[] = $value;// the same situation with $array[$key] = $value;
}
Resulted in this output:
If array elements are light there is possible to get 'Process exited with code 137.'
But if are higher than stdClass it kill all application.
Using foreach without using $key: `foreach ($array as &$value)`
generates: `Fatal error: Allowed memory size of...` - IMO this is better message for debugging what is wrong
But I expected this output instead:
Better message to be able to debug it, or possibility to use above construction :]
PHP Version
8.2
Operating System
Ubuntu 22