From b5d15b297598f65ab6ea08b852e2615eee0be6e8 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 3 Jan 2009 19:29:55 +0000 Subject: [PATCH] - MFH Prevent instantiation from Reflection --- Zend/zend_closures.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index f646550cbd..03a0e8516f 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -310,11 +310,24 @@ static HashTable *zend_closure_get_debug_info(zval *object, int *is_temp TSRMLS_ } /* }}} */ +/* {{{ proto Closure::__construct() + Private constructor preventing instantiation */ +ZEND_METHOD(Closure, __construct) +{ + zend_error(E_RECOVERABLE_ERROR, "Instantiation of 'Closure' is not allowed"); +} +/* }}} */ + +static const zend_function_entry closure_functions[] = { + ZEND_ME(Closure, __construct, NULL, ZEND_ACC_PRIVATE) + {NULL, NULL, NULL} +}; + void zend_register_closure_ce(TSRMLS_D) /* {{{ */ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, "Closure", NULL); + INIT_CLASS_ENTRY(ce, "Closure", closure_functions); zend_ce_closure = zend_register_internal_class(&ce TSRMLS_CC); zend_ce_closure->ce_flags |= ZEND_ACC_FINAL_CLASS; zend_ce_closure->create_object = zend_closure_new; -- 2.40.0