cvs: ZendEngine2 / zend_closures.c

[email protected] ("Marcus Boerger")
Newsgroups php.zend-engine.cvs
Message-ID <cvshelly1231010944@cvsserver>
helly		Sat Jan  3 19:29:04 2009 UTC

  Modified files:              
    /ZendEngine2	zend_closures.c 
  Log:
  - Prevent instantiation from Reflection
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_closures.c?r1=1.23&r2=1.24&diff_format=u
Index: ZendEngine2/zend_closures.c
diff -u ZendEngine2/zend_closures.c:1.23 ZendEngine2/zend_closures.c:1.24
--- ZendEngine2/zend_closures.c:1.23	Sat Jan  3 18:21:51 2009
+++ ZendEngine2/zend_closures.c	Sat Jan  3 19:29:04 2009
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_closures.c,v 1.23 2009/01/03 18:21:51 helly Exp $ */
+/* $Id: zend_closures.c,v 1.24 2009/01/03 19:29:04 helly Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -315,11 +315,24 @@
 }
 /* }}} */
 
+/* {{{ 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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.