Skip to content

Commit c20bde9

Browse files
committed
- Prevent instantiation from Reflection
1 parent 9535ca5 commit c20bde9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Zend/zend_closures.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,24 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_
315315
}
316316
/* }}} */
317317

318+
/* {{{ proto Closure::__construct()
319+
Private constructor preventing instantiation */
320+
ZEND_METHOD(Closure, __construct)
321+
{
322+
zend_error(E_RECOVERABLE_ERROR, "Instantiation of 'Closure' is not allowed");
323+
}
324+
/* }}} */
325+
326+
static const zend_function_entry closure_functions[] = {
327+
ZEND_ME(Closure, __construct, NULL, ZEND_ACC_PRIVATE)
328+
{NULL, NULL, NULL}
329+
};
330+
318331
void zend_register_closure_ce(TSRMLS_D) /* {{{ */
319332
{
320333
zend_class_entry ce;
321334

322-
INIT_CLASS_ENTRY(ce, "Closure", NULL);
335+
INIT_CLASS_ENTRY(ce, "Closure", closure_functions);
323336
zend_ce_closure = zend_register_internal_class(&ce TSRMLS_CC);
324337
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL_CLASS;
325338
zend_ce_closure->create_object = zend_closure_new;

0 commit comments

Comments
 (0)