Skip to content

Commit 2cb4ee5

Browse files
committed
Test PHP 8.3 static variable initializers
1 parent 8a2178f commit 2cb4ee5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/copy.c

+3
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,9 @@ static zend_op* pmmpthread_copy_opcodes(zend_op_array *op_array, zval *literals,
429429
case ZEND_FE_RESET_RW:
430430
case ZEND_ASSERT_CHECK:
431431
case ZEND_JMP_NULL:
432+
#if PHP_VERSION_ID >= 80300
433+
case ZEND_BIND_INIT_STATIC_OR_JMP:
434+
#endif
432435
opline->op2.jmp_addr = &copy[opline->op2.jmp_addr - op_array->opcodes];
433436
break;
434437
case ZEND_CATCH:
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test that PHP 8.3 static variable initializers work correctly
3+
--SKIPIF--
4+
<?php if(PHP_VERSION_ID < 80300) die("skip this test is for 8.3+ only"); ?>
5+
--FILE--
6+
<?php
7+
8+
use pmmp\thread\Thread;
9+
10+
function test() : void{
11+
static $var = sprintf("%s %s", "hello", "world");
12+
13+
var_dump($var);
14+
}
15+
16+
$t = new class extends Thread{
17+
public function run() : void{
18+
test();
19+
}
20+
};
21+
$t->start(Thread::INHERIT_ALL) && $t->join();
22+
?>
23+
--EXPECT--
24+
string(11) "hello world"

0 commit comments

Comments
 (0)