[php-src] master: Merge branch 'PHP-8.6'
| From: | ndossche | Date: | Fri, 30 Oct 2026 19:34:46 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143032@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-10-30T20:34:27+01:00
Commit: https://github.com/php/php-src/commit/6807461919c6d456ef9f822d9c78b0078ca2f59d
Raw diff: https://github.com/php/php-src/commit/6807461919c6d456ef9f822d9c78b0078ca2f59d.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
Fix JIT losing the called scope of self::/parent:: calls in included files
Changed paths:
A ext/opcache/tests/jit/init_static_method_call_002.phpt
A ext/opcache/tests/jit/init_static_method_call_002_include.inc
M ext/opcache/jit/zend_jit_ir.c
Diff:
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 2b2e0cac7902..9207ff411eb9 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -9414,7 +9414,8 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit,
(opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF)) {
if (op_array->fn_flags & ZEND_ACC_STATIC) {
scope_ref = ir_LOAD_A(jit_EX(This.value.ref));
- } else if (op_array->fn_flags & ZEND_ACC_CLOSURE) {
+ } else if ((op_array->fn_flags & ZEND_ACC_CLOSURE) || !op_array->function_name) {
+ /* Closures can be unbound, file/eval inherits This from the existing frame's scope. */
ir_ref if_object, values = IR_UNUSED;
if_object = ir_IF(ir_EQ(jit_Z_TYPE_ref(jit, jit_EX(This)), ir_CONST_U8(IS_OBJECT)));
diff --git a/ext/opcache/tests/jit/init_static_method_call_002.phpt
b/ext/opcache/tests/jit/init_static_method_call_002.phpt
new file mode 100644
index 000000000000..897c0377d6c3
--- /dev/null
+++ b/ext/opcache/tests/jit/init_static_method_call_002.phpt
@@ -0,0 +1,32 @@
+--TEST--
+JIT INIT_STATIC_METHOD_CALL: self:: in an included file keeps the called scope of a static caller
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.file_update_protection=0
+opcache.jit=tracing
+opcache.jit_hot_loop=1
+--EXTENSIONS--
+opcache
+--FILE--
+<?php
+
+class A {
+ public static function who() {
+ return static::class;
+ }
+
+ public static function test() {
+ include __DIR__ . '/init_static_method_call_002_include.inc';
+ }
+}
+
+class B extends A {}
+
+B::test();
+
+?>
+--EXPECT--
+B
+B
+B
diff --git a/ext/opcache/tests/jit/init_static_method_call_002_include.inc
b/ext/opcache/tests/jit/init_static_method_call_002_include.inc
new file mode 100644
index 000000000000..66ea277d2da9
--- /dev/null
+++ b/ext/opcache/tests/jit/init_static_method_call_002_include.inc
@@ -0,0 +1,4 @@
+<?php
+for ($i = 0; $i < 3; $i++) {
+ echo self::who(), "\n";
+}