From d18420fa4a186a9c6a18d17b5aa5b25c53d61c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 6 Mar 2023 13:15:02 +0100 Subject: [PATCH] Fix zend_compile_func_decl scope --- Zend/tests/closure_033.phpt | 2 +- Zend/tests/nested_method_and_function.phpt | 2 +- Zend/zend_compile.c | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Zend/tests/closure_033.phpt b/Zend/tests/closure_033.phpt index 720497bd2de1c..46517326d8043 100644 --- a/Zend/tests/closure_033.phpt +++ b/Zend/tests/closure_033.phpt @@ -23,7 +23,7 @@ $o->func(); ?> ===DONE=== --EXPECTF-- -{closure}() +Test::{closure}() Fatal error: Uncaught Error: Call to private method Test::func() from global scope in %s:%d Stack trace: diff --git a/Zend/tests/nested_method_and_function.phpt b/Zend/tests/nested_method_and_function.phpt index 5965a9274c3ce..2389e7b735cd4 100644 --- a/Zend/tests/nested_method_and_function.phpt +++ b/Zend/tests/nested_method_and_function.phpt @@ -35,5 +35,5 @@ string(3) "bar" string(12) "Baz\Foo::bar" string(7) "Baz\Foo" string(13) "Baz\{closure}" -string(13) "Baz\{closure}" +string(22) "Baz\Foo::Baz\{closure}" string(7) "Baz\Foo" diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 0774fb6d19a25..0344e02d740ef 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7215,6 +7215,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel) if (decl->kind == ZEND_AST_CLOSURE || decl->kind == ZEND_AST_ARROW_FUNC) { op_array->fn_flags |= ZEND_ACC_CLOSURE; + op_array->scope = CG(active_class_entry); } if (is_method) {