Hi again,

The attached patch:
1) adds "unset import" syntax for declaring a namespace to have local
import scope (it does NOT affect variable scope or the global
class/function table)
2) removes "namespace Name;" syntax (this I am happy to add this back in
if there is uproar)
3) fixes all misspellings of "coflict" in zend_compile.c (2 total)
4) uses a more intuitive error message "Namespace 'Foo' cannot be nested
(already within 'Bar' namespace)" for nested namespaces
5) updates tests to use brackets

it can also be found at
http://pear.php.net/~greg/namespace_brackets_unsetimport.patch.txt

After Stanislav's criticisms of my "smart import" namespace patch and
David's criticism of confusing dual syntax, I decided to take another
approach to the import issue.  Although I would rather only support one
use case of namespace blah {}, I do think that realistically PHP should
be as intuitive as possible.  Having a separate scope by default for
import that does not inherit from the global scope is not very intuitive.

So, instead of resetting current_import by default, this patch makes
import global by default and local by explicit syntax via:

namespace MyNamespace unset import {
}


For example:
<?php
import foo::bar;

namespace foo {
    class bar {
        function __construct()
        {
            echo __NAMESPACE__ . "::bar\n";
        }
    }
    // foo::bar
    new bar;
}


namespace gronk unset import {
    import foo::bar as foobar;
    // uses local import
    class bar extends foobar {
        function __construct()
        {
            echo __NAMESPACE__ . "::bar\n";
        }
    }
    // gronk::bar
    new bar;
    // foo::bar
    new foobar;
}

namespace last {
    // uses global import
    // foo::bar
    new bar;
}
// uses global import
// foo::bar
new bar;
?>

This code demonstrates that in the (useless) namespace last {}
declaration, we can access the global import.  This way, since import
conflicts are not the norm but the exception, they can be handled on a
case-by-case basis.  Let's remember that in most cases users will not be
declaring multiple namespaces, but instead doing this use case for the
import keyword:

<?php
require 'library1/foo.php';
require 'framework2/foo.php';

import framework2::foo as foo;
import library1::foo as bar;
...
?>

Again, the primary use case for multiple namespaces in the same file
that I hope to support is combining multiple pre-existing files into a
single file.  As each file is expected to be self-contained, this means
that by having import statements within the namespace {} declaration and
using unset import the files are guaranteed to combine with any other
separate file that follows these rules.  Even if authors do not use
unset import, it can easily be added by hand or automatically when
glomming the separate files into a single file.

Files with global imports will be out of luck if there are naming
conflicts with the global namespace (similar to today's pre-namespace
conundrum), but as class files or functions are almost always libraries
of some kind, this is unlikely if the documentation is clear on best
practices.

Greg
? halt_compiler_php6.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.762
diff -u -r1.762 zend_compile.c
--- Zend/zend_compile.c 20 Aug 2007 09:48:41 -0000      1.762
+++ Zend/zend_compile.c 22 Aug 2007 02:15:54 -0000
@@ -166,6 +166,7 @@
        CG(labels) = NULL;
        CG(current_namespace) = NULL;
        CG(current_import) = NULL;
+       CG(saved_import) = NULL;
 }
 /* }}} */
 
@@ -3192,7 +3193,7 @@
        /* Class name must not conflict with import names */
        if (CG(current_import) &&
            zend_u_hash_exists(CG(current_import), 
Z_TYPE(class_name->u.constant), lcname, lcname_len+1)) {
-               zend_error(E_COMPILE_ERROR, "Class name '%R' coflicts with 
import name", Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant));
+               zend_error(E_COMPILE_ERROR, "Class name '%R' conflicts with 
import name", Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant));
        }
 
        if (CG(current_namespace)) {
@@ -4971,11 +4972,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");
+               zend_error(E_COMPILE_ERROR, "Namespace '%R' cannot be nested 
(already within '%R' namespace)", Z_TYPE(name->u.constant), 
Z_UNIVAL(name->u.constant), Z_TYPE_P(CG(current_namespace)), 
Z_UNIVAL_P(CG(current_namespace)));
        }
        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) &&
@@ -4991,6 +4989,33 @@
 }
 /* }}} */
 
+void zend_do_end_namespace(TSRMLS_D) /* {{{ */
+{
+       if (CG(current_namespace)) {
+               zval_dtor(CG(current_namespace));
+               efree(CG(current_namespace));
+               CG(current_namespace) = NULL;
+       }
+       if (CG(saved_import)) {
+               if (CG(current_import)) {
+                       zend_hash_destroy(CG(current_import));
+                       efree(CG(current_import));
+                       CG(current_import) = NULL;
+               }
+               CG(current_import) = CG(saved_import);
+               CG(saved_import) = NULL;
+       }
+}
+/* }}} */
+
+/* within a namespace, do not use the global import list */
+void zend_do_local_import(TSRMLS_D) /* {{{ */
+{
+       CG(saved_import) = CG(current_import);
+       CG(current_import) = NULL;
+}
+/* }}} */
+
 void zend_do_import(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
 {
        unsigned int lcname_len;
@@ -5042,7 +5067,7 @@
        }
 
        if (zend_u_hash_exists(CG(class_table), Z_TYPE_P(name), lcname, 
lcname_len+1)) {
-               zend_error(E_COMPILE_ERROR, "Import name '%R' coflicts with 
defined class", Z_TYPE_P(name), Z_UNIVAL_P(name));
+               zend_error(E_COMPILE_ERROR, "Import name '%R' conflicts with 
defined class", Z_TYPE_P(name), Z_UNIVAL_P(name));
        }
 
        if (zend_u_hash_add(CG(current_import), Z_TYPE_P(name), lcname, 
lcname_len+1, &ns, sizeof(zval*), NULL) != SUCCESS) {
@@ -5068,6 +5093,11 @@
                efree(CG(current_import));
                CG(current_import) = NULL;
        }
+       if (CG(saved_import)) {
+               zend_hash_destroy(CG(saved_import));
+               efree(CG(saved_import));
+               CG(saved_import) = NULL;
+       }
 }
 /* }}} */
 
Index: Zend/zend_compile.h
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.h,v
retrieving revision 1.363
diff -u -r1.363 zend_compile.h
--- Zend/zend_compile.h 20 Aug 2007 09:48:41 -0000      1.363
+++ Zend/zend_compile.h 22 Aug 2007 02:15:55 -0000
@@ -521,6 +521,8 @@
 
 void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name 
TSRMLS_DC);
 void zend_do_namespace(znode *name TSRMLS_DC);
+void zend_do_end_namespace(TSRMLS_D);
+void zend_do_local_import(TSRMLS_D);
 void zend_do_import(znode *name, znode *new_name TSRMLS_DC);
 void zend_do_end_compilation(TSRMLS_D);
 
Index: Zend/zend_globals.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals.h,v
retrieving revision 1.168
diff -u -r1.168 zend_globals.h
--- Zend/zend_globals.h 12 Jul 2007 09:23:48 -0000      1.168
+++ Zend/zend_globals.h 22 Aug 2007 02:15:55 -0000
@@ -140,6 +140,7 @@
 
        zval      *current_namespace;
        HashTable *current_import;
+       HashTable *saved_import;
 
 #ifdef ZTS
        HashTable **static_members;
Index: Zend/zend_language_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.188
diff -u -r1.188 zend_language_parser.y
--- Zend/zend_language_parser.y 20 Aug 2007 09:48:41 -0000      1.188
+++ Zend/zend_language_parser.y 22 Aug 2007 02:15:56 -0000
@@ -171,11 +171,15 @@
        |       function_declaration_statement  { 
zend_do_early_binding(TSRMLS_C); }
        |       class_declaration_statement             { 
zend_do_early_binding(TSRMLS_C); }
        |       T_HALT_COMPILER '(' ')' ';'             { 
zend_do_halt_compiler_register(TSRMLS_C); YYACCEPT; }
-       |       T_NAMESPACE namespace_name ';'  { zend_do_namespace(&$2 
TSRMLS_CC); }
+       |       T_NAMESPACE namespace_name unimport '{' { zend_do_namespace(&$2 
TSRMLS_CC);} top_statement_list '}' { zend_do_end_namespace(TSRMLS_C); }
+       |       T_NAMESPACE namespace_name '{'  { zend_do_namespace(&$2 
TSRMLS_CC);} top_statement_list '}' { zend_do_end_namespace(TSRMLS_C); }
        |       T_IMPORT namespace_name ';'             { zend_do_import(&$2, 
NULL TSRMLS_CC); }
        |       T_IMPORT namespace_name T_AS T_STRING ';'       { 
zend_do_import(&$2, &$4 TSRMLS_CC); }
 ;
 
+unimport:
+       T_UNSET T_IMPORT { zend_do_local_import(TSRMLS_C); }
+;
 
 inner_statement_list:
                inner_statement_list  { zend_do_extended_info(TSRMLS_C); } 
inner_statement { HANDLE_INTERACTIVE(); }
Index: Zend/tests/ns_001.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_001.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_001.phpt
--- Zend/tests/ns_001.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_001.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 001: Class in namespace
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 class Foo {
 
@@ -25,6 +25,7 @@
 $y = new test::ns1::Foo;
 $y->bar();
 test::ns1::Foo::baz();
+}
 --EXPECT--
 test::ns1::Foo
 test::ns1::Foo
Index: Zend/tests/ns_002.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_002.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_002.phpt
--- Zend/tests/ns_002.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_002.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 002: Import in namespace
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 class Foo {
   static function bar() {
@@ -19,6 +19,7 @@
 Bar::bar();
 ns2::Foo::bar();
 ns1::Foo::bar();
+}
 --EXPECT--
 test::ns1::Foo
 test::ns1::Foo
Index: Zend/tests/ns_003.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_003.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_003.phpt
--- Zend/tests/ns_003.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_003.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,11 +2,12 @@
 003: Name conflict (ns name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 class Exception {
 }
 
 echo get_class(new Exception()),"\n";
+}
 --EXPECT--
 test::ns1::Exception
Index: Zend/tests/ns_004.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_004.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_004.phpt
--- Zend/tests/ns_004.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_004.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,8 +2,9 @@
 004: Name conflict (php name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 echo get_class(new Exception()),"\n";
+}
 --EXPECT--
 Exception
Index: Zend/tests/ns_005.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_005.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_005.phpt
--- Zend/tests/ns_005.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_005.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,11 +2,12 @@
 005: Name conflict (php name in case if ns name exists)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 class Exception {
 }
 
 echo get_class(new ::Exception()),"\n";
+}
 --EXPECT--
 Exception
Index: Zend/tests/ns_006.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_006.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_006.phpt
--- Zend/tests/ns_006.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_006.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,12 +2,13 @@
 006: Run-time name conflict (ns name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 class Exception {
 }
 
 $x = "test::ns1::Exception";
 echo get_class(new $x),"\n";
+}
 --EXPECT--
 test::ns1::Exception
Index: Zend/tests/ns_007.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_007.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_007.phpt
--- Zend/tests/ns_007.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_007.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,12 +2,13 @@
 007: Run-time name conflict (php name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 class Exception {
 }
 
 $x = "Exception";
 echo get_class(new $x),"\n";
+}
 --EXPECT--
 Exception
Index: Zend/tests/ns_008.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_008.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_008.phpt
--- Zend/tests/ns_008.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_008.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,12 +2,13 @@
 008: __NAMESPACE__ constant and runtime names (ns name)
 --FILE--
 <?php
-namespace test;
+namespace test {
 
 class foo {
 }
 
 $x = __NAMESPACE__ . "::foo"; 
 echo get_class(new $x),"\n";
+}
 --EXPECT--
 test::foo
Index: Zend/tests/ns_010.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_010.phpt,v
retrieving revision 1.2
diff -u -r1.2 ns_010.phpt
--- Zend/tests/ns_010.phpt      27 Jul 2007 14:53:23 -0000      1.2
+++ Zend/tests/ns_010.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 010: Accesing internal namespace class
 --FILE--
 <?php
-namespace X;
+namespace X {
 import X as Y;
 class Foo {    
        const C = "const ok\n";
@@ -30,6 +30,7 @@
 echo X::Foo::$var;
 echo Y::Foo::$var;
 echo ::X::Foo::$var;
+}
 --EXPECT--
 class ok
 class ok
Index: Zend/tests/ns_011.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_011.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_011.phpt
--- Zend/tests/ns_011.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_011.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 011: Function in namespace
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 function foo() {
   echo __FUNCTION__,"\n";
@@ -16,7 +16,7 @@
 function bar() {
   echo __FUNCTION__,"\n";
 }
-
+}
 --EXPECT--
 test::ns1::foo
 test::ns1::foo
Index: Zend/tests/ns_012.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_012.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_012.phpt
--- Zend/tests/ns_012.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_012.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 012: Import in namespace and functions
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 function foo() {
   echo __FUNCTION__,"\n";
@@ -23,7 +23,7 @@
 function bar() {
   echo __FUNCTION__,"\n";
 }
-
+}
 --EXPECT--
 test::ns1::foo
 test::ns1::bar
Index: Zend/tests/ns_013.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_013.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_013.phpt
--- Zend/tests/ns_013.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_013.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,12 +2,13 @@
 013: Name conflict and functions (ns name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 function strlen($x) {
        return __FUNCTION__;
 }
 
 echo strlen("Hello"),"\n";
+}
 --EXPECT--
 test::ns1::strlen
Index: Zend/tests/ns_014.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_014.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_014.phpt
--- Zend/tests/ns_014.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_014.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,8 +2,9 @@
 014: Name conflict and functions (php name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 echo strlen("Hello"),"\n";
+}
 --EXPECT--
 5
Index: Zend/tests/ns_015.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_015.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_015.phpt
--- Zend/tests/ns_015.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_015.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,13 +2,14 @@
 015: Name conflict and functions (php name in case if ns name exists)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 function strlen($x) {
        return __FUNCTION__;
 }
 
 echo ::strlen("Hello"),"\n";
+}
 --EXPECT--
 5
 
Index: Zend/tests/ns_016.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_016.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_016.phpt
--- Zend/tests/ns_016.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_016.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 016: Run-time name conflict and functions (ns name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 function strlen($x) {
        return __FUNCTION__;
@@ -10,5 +10,6 @@
 
 $x = "test::ns1::strlen";
 echo $x("Hello"),"\n";
+}
 --EXPECT--
 test::ns1::strlen
Index: Zend/tests/ns_017.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_017.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_017.phpt
--- Zend/tests/ns_017.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_017.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 017: Run-time name conflict and functions (php name)
 --FILE--
 <?php
-namespace test::ns1;
+namespace test::ns1 {
 
 function strlen($x) {
        return __FUNCTION__;
@@ -10,5 +10,6 @@
 
 $x = "strlen";
 echo $x("Hello"),"\n";
+}
 --EXPECT--
 5
\ No newline at end of file
Index: Zend/tests/ns_018.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_018.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_018.phpt
--- Zend/tests/ns_018.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_018.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 018: __NAMESPACE__ constant and runtime names (ns name)
 --FILE--
 <?php
-namespace test;
+namespace test {
 
 function foo() {
        return __FUNCTION__;
@@ -10,5 +10,6 @@
 
 $x = __NAMESPACE__ . "::foo"; 
 echo $x(),"\n";
+}
 --EXPECT--
 test::foo
Index: Zend/tests/ns_020.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_020.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_020.phpt
--- Zend/tests/ns_020.phpt      27 Jul 2007 13:41:36 -0000      1.1
+++ Zend/tests/ns_020.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 020: Accesing internal namespace function
 --FILE--
 <?php
-namespace X;
+namespace X {
 import X as Y;
 function foo() {
        echo __FUNCTION__,"\n";
@@ -11,6 +11,7 @@
 X::foo();
 Y::foo();
 ::X::foo();
+}
 --EXPECT--
 X::foo
 X::foo
Index: Zend/tests/ns_021.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_021.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_021.phpt
--- Zend/tests/ns_021.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_021.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 021: Name search priority (first look into namespace)
 --FILE--
 <?php
-namespace test;
+namespace test {
 
 class Test {
        static function foo() {
@@ -17,6 +17,7 @@
 foo();
 test::foo();
 test::test::foo();
+}
 --EXPECT--
 test::foo
 test::Test::foo
Index: Zend/tests/ns_022.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_022.phpt,v
retrieving revision 1.2
diff -u -r1.2 ns_022.phpt
--- Zend/tests/ns_022.phpt      26 Jul 2007 08:32:52 -0000      1.2
+++ Zend/tests/ns_022.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 022: Name search priority (first look into import, then into current namespace 
and then for class)
 --FILE--
 <?php
-namespace a::b::c;
+namespace a::b::c {
 
 import a::b::c as test;
 
@@ -14,6 +14,7 @@
 
 test::foo();
 ::test::foo();
+}
 --EXPECT--
 a::b::c::foo
 Test::foo
Index: Zend/tests/ns_023.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_023.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_023.phpt
--- Zend/tests/ns_023.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_023.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,9 +2,10 @@
 023: __NAMESPACE__ constant
 --FILE--
 <?php
-namespace test::foo;
+namespace test::foo {
 
 var_dump(__NAMESPACE__);
+}
 --EXPECT--
 string(9) "test::foo"
 --UEXPECT--
Index: Zend/tests/ns_025.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_025.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_025.phpt
--- Zend/tests/ns_025.phpt      26 Jul 2007 08:32:52 -0000      1.1
+++ Zend/tests/ns_025.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 025: Name ambiguity (class name & part of namespace name)
 --FILE--
 <?php
-namespace Foo::Bar;
+namespace Foo::Bar {
 
 class Foo {
   function __construct() {
@@ -17,6 +17,7 @@
 Foo::Bar();
 $x = new Foo::Bar::Foo;
 Foo::Bar::Foo::Bar();
+}
 --EXPECT--
 Foo::Bar::Foo
 Foo::Bar::Foo
Index: Zend/tests/ns_026.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_026.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_026.phpt
--- Zend/tests/ns_026.phpt      26 Jul 2007 08:32:52 -0000      1.1
+++ Zend/tests/ns_026.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 026: Name ambiguity (class name & namespace name)
 --FILE--
 <?php
-namespace Foo;
+namespace Foo {
 
 class Foo {
   function __construct() {
@@ -22,6 +22,7 @@
 $x = new Foo::Foo;
 Foo::Foo::Bar();
 ::Foo::Bar();
+}
 --EXPECT--
 Method - Foo::Foo::__construct
 Method - Foo::Foo::Bar
Index: Zend/tests/ns_027.inc
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_027.inc,v
retrieving revision 1.1
diff -u -r1.1 ns_027.inc
--- Zend/tests/ns_027.inc       26 Jul 2007 08:32:52 -0000      1.1
+++ Zend/tests/ns_027.inc       22 Aug 2007 02:15:56 -0000
@@ -1,5 +1,5 @@
 <?php
-namespace Foo::Bar;
+namespace Foo::Bar {
 
 class Foo {
   function __construct() {
@@ -9,3 +9,4 @@
        echo __CLASS__,"\n";
   }
 }
+}
\ No newline at end of file
Index: Zend/tests/ns_028.inc
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_028.inc,v
retrieving revision 1.1
diff -u -r1.1 ns_028.inc
--- Zend/tests/ns_028.inc       26 Jul 2007 08:32:52 -0000      1.1
+++ Zend/tests/ns_028.inc       22 Aug 2007 02:15:56 -0000
@@ -1,5 +1,5 @@
 <?php
-namespace Foo;
+namespace Foo {
 
 class Foo {
   function __construct() {
@@ -13,3 +13,4 @@
 function Bar() {
   echo "Func   - ".__FUNCTION__."\n";
 }
+}
\ No newline at end of file
Index: Zend/tests/ns_029.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_029.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_029.phpt
--- Zend/tests/ns_029.phpt      26 Jul 2007 08:32:52 -0000      1.1
+++ Zend/tests/ns_029.phpt      22 Aug 2007 02:15:56 -0000
@@ -9,4 +9,4 @@
 
 new Foo();
 --EXPECTF--
-Fatal error: Class name 'Foo' coflicts with import name in %sns_029.php on 
line 4
+Fatal error: Class name 'Foo' conflicts with import name in %sns_029.php on 
line 4
Index: Zend/tests/ns_030.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_030.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_030.phpt
--- Zend/tests/ns_030.phpt      26 Jul 2007 08:32:52 -0000      1.1
+++ Zend/tests/ns_030.phpt      22 Aug 2007 02:15:56 -0000
@@ -9,4 +9,4 @@
 
 new Foo();
 --EXPECTF--
-Fatal error: Import name 'Foo' coflicts with defined class in %sns_030.php on 
line 5
+Fatal error: Import name 'Foo' conflicts with defined class in %sns_030.php on 
line 5
Index: Zend/tests/ns_031.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_031.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_031.phpt
--- Zend/tests/ns_031.phpt      12 Jul 2007 09:23:48 -0000      1.1
+++ Zend/tests/ns_031.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 031: Namespace support for user functions (ns name)
 --FILE--
 <?php
-namespace test;
+namespace test {
 
 class Test {
        static function foo() {
@@ -16,6 +16,7 @@
 
 call_user_func(__NAMESPACE__."::foo");
 call_user_func(__NAMESPACE__."::test::foo");
+}
 --EXPECT--
 test::foo
 test::Test::foo
Index: Zend/tests/ns_034.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_034.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_034.phpt
--- Zend/tests/ns_034.phpt      27 Jul 2007 09:04:12 -0000      1.1
+++ Zend/tests/ns_034.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 034: Support for namespaces in compile-time constant reference
 --FILE--
 <?php
-namespace A;
+namespace A {
 import A as B;
 class Foo {
        const C = "ok\n";
@@ -27,6 +27,7 @@
 f2();
 f3();
 f4();
+}
 --EXPECT--
 ok
 ok
Index: Zend/tests/ns_035.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_035.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_035.phpt
--- Zend/tests/ns_035.phpt      27 Jul 2007 09:04:12 -0000      1.1
+++ Zend/tests/ns_035.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 035: Name ambiguity in compile-time constant reference (php name)
 --FILE--
 <?php
-namespace A;
+namespace A {
 function f1($x = ArrayObject::STD_PROP_LIST) {
        var_dump($x);
 }
@@ -13,6 +13,7 @@
 var_dump(::ArrayObject::STD_PROP_LIST);
 f1();
 f2();
+}
 --EXPECT--
 int(1)
 int(1)
Index: Zend/tests/ns_036.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_036.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_036.phpt
--- Zend/tests/ns_036.phpt      27 Jul 2007 09:04:12 -0000      1.1
+++ Zend/tests/ns_036.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 036: Name ambiguity in compile-time constant reference (ns name)
 --FILE--
 <?php
-namespace A;
+namespace A {
 import A as B;
 class ArrayObject {
        const STD_PROP_LIST = 2;
@@ -32,6 +32,7 @@
 f3();
 f4();
 f5();
+}
 --EXPECT--
 int(2)
 int(1)
Index: Zend/tests/ns_037.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_037.phpt,v
retrieving revision 1.2
diff -u -r1.2 ns_037.phpt
--- Zend/tests/ns_037.phpt      27 Jul 2007 14:53:23 -0000      1.2
+++ Zend/tests/ns_037.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,7 +2,7 @@
 037: Name ambiguity (namespace name or namespace's class name)
 --FILE--
 <?php
-namespace X;
+namespace X {
 import X as Y;
 class X {
        const C = "const ok\n";
@@ -30,6 +30,7 @@
 echo X::X::$var;
 echo Y::X::$var;
 echo ::X::X::$var;
+}
 --EXPECT--
 class ok
 class ok
Index: Zend/tests/ns_038.phpt
===================================================================
RCS file: /repository/ZendEngine2/tests/ns_038.phpt,v
retrieving revision 1.1
diff -u -r1.1 ns_038.phpt
--- Zend/tests/ns_038.phpt      1 Aug 2007 11:44:25 -0000       1.1
+++ Zend/tests/ns_038.phpt      22 Aug 2007 02:15:56 -0000
@@ -2,12 +2,13 @@
 038: Name ambiguity (namespace name or internal class name)
 --FILE--
 <?php
-namespace Exception;
+namespace Exception {
 function foo() {
   echo "ok\n";
 }
 Exception::foo();
 Exception::bar();
+}
 --EXPECTF--
 ok
 
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 02:15:56 -0000
@@ -0,0 +1,16 @@
+--TEST--
+039: nested namespace declaration
+--FILE--
+<?php
+namespace Exception {
+namespace Oops {
+function foo() {
+  echo "ok\n";
+}
+Exception::foo();
+Exception::bar();
+}
+}
+--EXPECTF--
+Fatal error: Namespace 'Oops' cannot be nested (already within 'Exception' 
namespace) in %sns_039.php on line 3
+
Index: Zend/tests/ns_040.phpt
===================================================================
RCS file: Zend/tests/ns_040.phpt
diff -N Zend/tests/ns_040.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_040.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,15 @@
+--TEST--
+040: namespace not first declaration
+--FILE--
+<?php
+$a = 'oops';
+namespace Exception {
+function foo() {
+  echo "ok\n";
+}
+}
+Exception::foo();
+--EXPECT--
+ok
+
+
Index: Zend/tests/ns_041.phpt
===================================================================
RCS file: Zend/tests/ns_041.phpt
diff -N Zend/tests/ns_041.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_041.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,13 @@
+--TEST--
+041: namespace with brackets, function declaration
+--FILE--
+<?php
+namespace Exception {
+function foo() {
+  echo "ok\n";
+}
+}
+Exception::foo();
+--EXPECTF--
+ok
+
Index: Zend/tests/ns_042.phpt
===================================================================
RCS file: Zend/tests/ns_042.phpt
diff -N Zend/tests/ns_042.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_042.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,15 @@
+--TEST--
+042: namespace with brackets, class declaration
+--FILE--
+<?php
+namespace Exception {
+class test {
+static function foo() {
+  echo "ok\n";
+}
+}
+}
+Exception::test::foo();
+--EXPECTF--
+ok
+
Index: Zend/tests/ns_043.phpt
===================================================================
RCS file: Zend/tests/ns_043.phpt
diff -N Zend/tests/ns_043.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_043.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,20 @@
+--TEST--
+043: namespace with brackets, class declaration + function declaration
+--FILE--
+<?php
+namespace Exception {
+class test {
+static function foo() {
+  echo "ok\n";
+}
+}
+function foo() {
+  echo "ok\n";
+}
+}
+Exception::test::foo();
+Exception::foo();
+--EXPECTF--
+ok
+ok
+
Index: Zend/tests/ns_044.phpt
===================================================================
RCS file: Zend/tests/ns_044.phpt
diff -N Zend/tests/ns_044.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_044.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,34 @@
+--TEST--
+044: namespace with brackets, two namespace declarations
+--FILE--
+<?php
+namespace Exception {
+class test {
+static function foo() {
+  echo "ok\n";
+}
+}
+function foo() {
+  echo "ok\n";
+}
+}
+Exception::test::foo();
+Exception::foo();
+namespace Second {
+class test {
+static function foo() {
+  echo "ok\n";
+}
+}
+function foo() {
+  echo "ok\n";
+}
+}
+Second::test::foo();
+Second::foo();
+--EXPECTF--
+ok
+ok
+ok
+ok
+
Index: Zend/tests/ns_045.phpt
===================================================================
RCS file: Zend/tests/ns_045.phpt
diff -N Zend/tests/ns_045.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_045.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,30 @@
+--TEST--
+045: illegal nested namespace with brackets
+--FILE--
+<?php
+namespace Exception {
+class test {
+static function foo() {
+  echo "ok\n";
+}
+}
+function foo() {
+  echo "ok\n";
+}
+test::foo();
+foo();
+namespace Second {
+class test {
+static function foo() {
+  echo "ok\n";
+}
+}
+function foo() {
+  echo "ok\n";
+}
+}
+}
+Second::test::foo();
+Second::foo();
+--EXPECTF--
+Fatal error: Namespace 'Second' cannot be nested (already within 'Exception' 
namespace) in %sns_045.php on line 13
\ No newline at end of file
Index: Zend/tests/ns_046.phpt
===================================================================
RCS file: Zend/tests/ns_046.phpt
diff -N Zend/tests/ns_046.phpt
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Zend/tests/ns_046.phpt      22 Aug 2007 02:15:56 -0000
@@ -0,0 +1,35 @@
+--TEST--
+046: unset import
+--FILE--
+<?php
+namespace foo {
+       class bar {
+               function __construct()
+               {
+                       echo __NAMESPACE__ . "::bar\n";
+               }
+       }
+       new bar;
+}
+import foo::bar;
+namespace gronk unset import {
+       import foo::bar as gronk;
+       class bar extends gronk {
+               function __construct()
+               {
+                       echo __NAMESPACE__ . "::bar\n";
+               }
+       }
+       new bar;
+       new gronk;
+}
+namespace last {
+       new bar;
+}
+new bar();
+--EXPECT--
+foo::bar
+gronk::bar
+foo::bar
+foo::bar
+foo::bar
\ No newline at end of file

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to