From 903bff5f0693b9ff59312e4f35a3f5a11dbbd688 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 29 Sep 2013 11:51:44 +0100 Subject: [PATCH] avoid clashes in the global scope by using filename in class name --- Zend/zend_compile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f6791ea59f5dd..9e6e8578ea9c0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2252,7 +2252,15 @@ void zend_do_create_anon_class(znode *result TSRMLS_DC) { /* {{{ */ prefix_name += Z_STRLEN_P( CG(current_namespace)) + sizeof("\\")-1; } - } else prefix_name = "Class"; + } else { + /* use filename as prefix for class */ + prefix_name = CG(active_op_array)->filename; + } + } + + if (!prefix_name) { + /* this shouldn't happen, possibly emit a warning ? */ + prefix_name = "Class"; } /* populate znode constant with generated anonymous class name */