Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -9389,7 +9389,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) {
/* Closured can be unbound, file/eval inherits This from the existing frame's scope. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Closured -> Closures.

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)));
Expand Down
32 changes: 32 additions & 0 deletions ext/opcache/tests/jit/init_static_method_call_002.phpt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
for ($i = 0; $i < 3; $i++) {
echo self::who(), "\n";
}
Loading