? multiple_namespace.patch.txt ? namespace.patch.txt ? namespace_brackets_unsetimport.patch.txt ? namespace_smartimport.patch.txt Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.764 diff -u -r1.764 zend_compile.c --- Zend/zend_compile.c 22 Aug 2007 07:39:37 -0000 1.764 +++ Zend/zend_compile.c 22 Aug 2007 23:15:02 -0000 @@ -4966,11 +4966,8 @@ unsigned int lcname_len; zstr lcname; - if (CG(active_op_array)->last > 0) { - zend_error(E_COMPILE_ERROR, "Namespace declaration statement has to be the very first statement in the script"); - } - if (CG(current_namespace)) { - zend_error(E_COMPILE_ERROR, "Namespace cannot be declared twice"); + if (!CG(current_namespace) && CG(active_op_array)->last > 0) { + zend_error(E_COMPILE_ERROR, "First namespace declaration statement has to be the first statement in the script"); } lcname = zend_u_str_case_fold(Z_TYPE(name->u.constant), Z_UNIVAL(name->u.constant), Z_UNILEN(name->u.constant), 0, &lcname_len); if (((lcname_len == sizeof("self")-1) && @@ -4981,6 +4978,16 @@ } efree(lcname.v); + if (CG(current_namespace)) { + zval_dtor(CG(current_namespace)); + efree(CG(current_namespace)); + } + if (CG(current_import)) { + zend_hash_destroy(CG(current_import)); + efree(CG(current_import)); + } + CG(current_import) = NULL; + ALLOC_ZVAL(CG(current_namespace)); *CG(current_namespace) = name->u.constant; } Index: Zend/tests/ns_039.phpt =================================================================== RCS file: Zend/tests/ns_039.phpt diff -N Zend/tests/ns_039.phpt --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Zend/tests/ns_039.phpt 22 Aug 2007 23:15:03 -0000 @@ -0,0 +1,35 @@ +--TEST-- +039: two namespace declarations +--FILE-- +