Skip to content

Commit b2ea183

Browse files
committed
handle nesting classes in functions
1 parent cd468a6 commit b2ea183

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
@@ -9157,6 +9157,12 @@ static void zend_compile_enum_backing_type(zend_class_entry *ce, zend_ast *enum_
91579157
HashTable *inner_class_queue = NULL;
91589158

91599159
static void zend_defer_class_decl(zend_ast *ast) {
9160+
ZEND_ASSERT(CG(active_class_entry));
9161+
9162+
if (CG(active_op_array)->function_name) {
9163+
zend_error_noreturn(E_COMPILE_ERROR, "Class declarations may not be declared inside functions");
9164+
}
9165+
91609166
if (inner_class_queue == NULL) {
91619167
ALLOC_HASHTABLE(inner_class_queue);
91629168
zend_hash_init(inner_class_queue, 8, NULL, ZVAL_PTR_DTOR, 0);

0 commit comments

Comments
 (0)