From: Dmitry Stogov Date: Wed, 7 Nov 2007 09:13:50 +0000 (+0000) Subject: T_IMPORT -> T_USE X-Git-Tag: RELEASE_1_3_1~701 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7d87bebc93e9937ed46f6762eed4a20c4e5b8d6;p=php T_IMPORT -> T_USE --- diff --git a/README.namespaces b/README.namespaces index 80321f2ce4..310adcc884 100755 --- a/README.namespaces +++ b/README.namespaces @@ -39,8 +39,8 @@ Namespace or class name can be imported: -import statement only defines name aliasing. It may create name alias for -namespace or class. The simple form of statement "import A::B::C::D;" is -equivalent to "import A::B::C::D as D;". Import statement can be used at any +The use statement only defines name aliasing. It may create name alias for +namespace or class. The simple form of statement "use A::B::C::D;" is +equivalent to "use A::B::C::D as D;". The use statement can be used at any time in the global scope (not inside function/class) and takes effect from the point of definition down to the end of file. It is recommended however to -place imports at the beginning of the file. Import statements have effect -only on the file where they appear. +place the use statements at the beginning of the file. The use statements have +effect only on the file where they appear. The special "empty" namespace (:: prefix) is useful as explicit global namespace qualification. All class and function names started from :: @@ -83,10 +83,10 @@ In global namespace __NAMESPACE__ constant has the value of empty string. Names inside namespace are resolved according to the following rules: 1) all qualified names are translated during compilation according to -current import rules. So if we have "import A::B::C" and then "C::D::e()" +current import rules. So if we have "use A::B::C" and then "C::D::e()" it is translated to "A::B::C::D::e()". 2) unqualified class names translated during compilation according to -current import rules. So if we have "import A::B::C" and then "new C()" it +current import rules. So if we have "use A::B::C" and then "new C()" it is translated to "new A::B::C()". 3) inside namespace, calls to unqualified functions that are defined in current namespace (and are known at the time the call is parsed) are diff --git a/Zend/tests/bug42859.phpt b/Zend/tests/bug42859.phpt index 6464f9b4c7..475c583465 100755 --- a/Zend/tests/bug42859.phpt +++ b/Zend/tests/bug42859.phpt @@ -5,8 +5,8 @@ Bug #42859 import always conflicts with internal classes namespace Foo; class Ex {} -import Blah::Exception; -import Blah::Ex; +use Blah::Exception; +use Blah::Ex; ?> --EXPECTF-- Fatal error: Import name 'Ex' conflicts with defined class in %sbug42859.php on line 6 \ No newline at end of file diff --git a/Zend/tests/ns_002.phpt b/Zend/tests/ns_002.phpt index 4b17012a94..7faca97cd3 100755 --- a/Zend/tests/ns_002.phpt +++ b/Zend/tests/ns_002.phpt @@ -10,9 +10,9 @@ class Foo { } } -import test::ns1::Foo as Bar; -import test::ns1 as ns2; -import test::ns1; +use test::ns1::Foo as Bar; +use test::ns1 as ns2; +use test::ns1; Foo::bar(); test::ns1::Foo::bar(); diff --git a/Zend/tests/ns_010.phpt b/Zend/tests/ns_010.phpt index 7be99e49bf..95172e0ec3 100755 --- a/Zend/tests/ns_010.phpt +++ b/Zend/tests/ns_010.phpt @@ -3,7 +3,7 @@ --FILE-- "import" { - return T_IMPORT; -} - "use" { return T_USE; }