Skip to content

Commit 1ed30e9

Browse files
committed
prevent nesting inside methods
1 parent 7d809db commit 1ed30e9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Zend/zend_compile.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9150,6 +9150,12 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
91509150
}
91519151

91529152
zend_assert_valid_class_name(unqualified_name, type);
9153+
9154+
// check to make sure we are in a class body and not a function body
9155+
if (CG(active_class_entry) && CG(active_op_array)->function_name) {
9156+
zend_error_noreturn(E_COMPILE_ERROR, "Class declarations may not be nested");
9157+
}
9158+
91539159
if (CG(active_class_entry)) {
91549160
// we have a nested class that needs to be renamed
91559161
// so append the unqualified name to the nested parent name

0 commit comments

Comments
 (0)