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.
36 lines
489 B
36 lines
489 B
--TEST--
|
|
static variable dynamic initializer runs only once
|
|
--FILE--
|
|
<?php
|
|
|
|
function make_static_items(int $seed): array
|
|
{
|
|
echo "init:$seed\n";
|
|
return [$seed];
|
|
}
|
|
|
|
function use_static_items(int $seed): void
|
|
{
|
|
static $items = make_static_items($seed);
|
|
var_dump($items);
|
|
$items[] = $seed;
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
use_static_items(10);
|
|
use_static_items(20);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
init:10
|
|
array(1) {
|
|
[0]=>
|
|
int(10)
|
|
}
|
|
array(2) {
|
|
[0]=>
|
|
int(10)
|
|
[1]=>
|
|
int(10)
|
|
}
|
|
|