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
}
}
-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();
--FILE--
<?php
namespace X;
-import X as Y;
+use X as Y;
class Foo {
const C = "const ok\n";
static $var = "var ok\n";
echo __FUNCTION__,"\n";
}
-import test::ns1 as ns2;
-import test as ns3;
+use test::ns1 as ns2;
+use test as ns3;
foo();
bar();
--FILE--
<?php
namespace X;
-import X as Y;
+use X as Y;
function foo() {
echo __FUNCTION__,"\n";
}
<?php
namespace a::b::c;
-import a::b::c as test;
+use a::b::c as test;
require "ns_022.inc";
029: Name ambiguity (class name & import name)
--FILE--
<?php
-import A::B as Foo;
+use A::B as Foo;
class Foo {
}
class Foo {
}
-import A::B as Foo;
+use A::B as Foo;
new Foo();
--EXPECTF--
033: Import statement with non-compound name
--FILE--
<?php
-import A;
+use A;
--EXPECTF--
-Warning: The import statement with non-compound name 'A' has no effect in %sns_033.php on line 2
+Warning: The use statement with non-compound name 'A' has no effect in %sns_033.php on line 2
--FILE--
<?php
namespace A;
-import A as B;
+use A as B;
class Foo {
const C = "ok\n";
}
--FILE--
<?php
namespace A;
-import A as B;
+use A as B;
class ArrayObject {
const STD_PROP_LIST = 2;
}
--FILE--
<?php
namespace X;
-import X as Y;
+use X as Y;
class X {
const C = "const ok\n";
static $var = "var ok\n";
--FILE--
<?php
namespace X;
-import X as Y;
+use X as Y;
const A = "ok\n";
const B = A;
const C = array(A);
const FOO = "ok\n";
-import test::ns1 as ns2;
-import test as ns3;
+use test::ns1 as ns2;
+use test as ns3;
echo FOO;
echo test::ns1::FOO;
}
/* }}} */
-void zend_do_import(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
+void zend_do_use(znode *ns_name, znode *new_name TSRMLS_DC) /* {{{ */
{
unsigned int lcname_len;
zstr lcname;
if (new_name) {
name = &new_name->u.constant;
} else {
- /* The form "import A::B" is eqivalent to "import A::B as B".
- So we extract the last part of compound name ti use as a new_name */
+ /* The form "use A::B" is eqivalent to "use A::B as B".
+ So we extract the last part of compound name to use as a new_name */
name = &tmp;
if (UG(unicode)) {
UChar *p = u_memrchr(Z_USTRVAL_P(ns), ':', Z_USTRLEN_P(ns));
zend_error(E_COMPILE_ERROR, "Cannot reuse import name");
}
if (warn) {
- zend_error(E_WARNING, "The import statement with non-compound name '%R' has no effect", Z_TYPE_P(name), Z_UNIVAL_P(name));
+ zend_error(E_WARNING, "The use statement with non-compound name '%R' has no effect", Z_TYPE_P(name), Z_UNIVAL_P(name));
}
efree(lcname.v);
zval_dtor(name);
void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC);
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_import(znode *name, znode *new_name TSRMLS_DC);
+void zend_do_use(znode *name, znode *new_name TSRMLS_DC);
void zend_do_end_compilation(TSRMLS_D);
ZEND_API void function_add_ref(zend_function *function TSRMLS_DC);
%token T_BINARY_DOUBLE
%token T_BINARY_HEREDOC
%token T_NAMESPACE
-%token T_IMPORT
%token T_NS_C
%% /* Rules */
| 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_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); }
+ | T_USE namespace_name ';' { zend_do_use(&$2, NULL TSRMLS_CC); }
+ | T_USE namespace_name T_AS T_STRING ';' { zend_do_use(&$2, &$4 TSRMLS_CC); }
| constant_declaration ';'
;
| T_ECHO echo_expr_list ';'
| T_INLINE_HTML { zend_do_echo(&$1, 1 TSRMLS_CC); }
| expr ';' { zend_do_free(&$1 TSRMLS_CC); }
- | T_USE use_filename ';' { zend_error(E_COMPILE_ERROR,"use: Not yet supported. Please use include_once() or require_once()"); zval_dtor(&$2.u.constant); }
| T_UNSET '(' unset_variables ')' ';'
| T_FOREACH '(' variable T_AS
{ zend_do_foreach_begin(&$1, &$2, &$3, &$4, 1 TSRMLS_CC); }
variable { zend_do_end_variable_parse(BP_VAR_UNSET, 0 TSRMLS_CC); zend_do_unset(&$1 TSRMLS_CC); }
;
-use_filename:
- T_CONSTANT_ENCAPSED_STRING { $$ = $1; }
- | '(' T_CONSTANT_ENCAPSED_STRING ')' { $$ = $2; }
-;
-
-
function_declaration_statement:
unticked_function_declaration_statement { zend_do_ticks(TSRMLS_C); }
;
return T_NAMESPACE;
}
-<ST_IN_SCRIPTING>"import" {
- return T_IMPORT;
-}
-
<ST_IN_SCRIPTING>"use" {
return T_USE;
}