TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
582 B
29 lines
582 B
--TEST--
|
|
std containers allow non-structural element updates during foreach
|
|
--FILE--
|
|
<?php
|
|
|
|
function main(): void
|
|
{
|
|
$vector = std::vector(Type::Int);
|
|
$vector[] = 1;
|
|
$vector[] = 2;
|
|
foreach ($vector as $vectorKey => $vectorValue) {
|
|
$vector[$vectorKey] += 10;
|
|
}
|
|
var_dump($vector[0], $vector[1]);
|
|
|
|
$map = std::ordered_map(Type::String, Type::Int);
|
|
$map['a'] = 3;
|
|
$map['b'] = 4;
|
|
foreach ($map as $mapKey => $mapValue) {
|
|
$map[$mapKey] += 20;
|
|
}
|
|
var_dump($map['a'], $map['b']);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(11)
|
|
int(12)
|
|
int(23)
|
|
int(24)
|
|
|