diff options
author | Felipe Pena <felipe@php.net> | 2011-07-02 17:12:20 +0000 |
---|---|---|
committer | Felipe Pena <felipe@php.net> | 2011-07-02 17:12:20 +0000 |
commit | 0124c28610ace0814720821060142b3309cd5f87 (patch) | |
tree | ec4d1d6b3cec1e79ce6cec318bd74c1333eac0bc /Zend | |
parent | b06e62d4fe2171c618fe440afa4b9e2a81861592 (diff) | |
download | php-git-0124c28610ace0814720821060142b3309cd5f87.tar.gz |
- Fixed bug #55086 (Namespace alias does not work inside trait's use block)
patch by: Pierrick
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/bug55086.phpt | 36 | ||||
-rw-r--r-- | Zend/zend_compile.c | 2 | ||||
-rw-r--r-- | Zend/zend_language_parser.y | 4 |
3 files changed, 40 insertions, 2 deletions
diff --git a/Zend/tests/bug55086.phpt b/Zend/tests/bug55086.phpt new file mode 100644 index 0000000000..9a5c747b9f --- /dev/null +++ b/Zend/tests/bug55086.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #55086 (Namespace alias does not work inside trait's use block) +--FILE-- +<?php +namespace N1 { + + trait T1 { + public function hello() { return 'hello from t1'; } + } + + trait T2 { + public function hello() { return 'hello from t2'; } + } + +} +namespace N2 { + use N1\T1; + use N1\T2; + class A { + use T1, T2 { + T1::hello insteadof T2; + T1::hello as foo; + } + } + $a = new A; + echo $a->hello(), PHP_EOL; + echo $a->foo(), PHP_EOL; + try { + } catch(namespace \Foo $e) + { + } +} +?> +--EXPECT-- +hello from t1 +hello from t1 diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 7842ec8f2e..5f9cef311b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4052,6 +4052,8 @@ void zend_prepare_reference(znode *result, znode *class_name, znode *method_name /* REM: There should not be a need for copying, zend_do_begin_class_declaration is also just using that string */ if (class_name) { + ulong fetch_type = ZEND_FETCH_CLASS_GLOBAL; + zend_resolve_class_name(class_name, &fetch_type, 1 TSRMLS_CC); method_ref->class_name = Z_STRVAL(class_name->u.constant); method_ref->cname_len = Z_STRLEN(class_name->u.constant); } else { diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 3d774bff25..4dd5bdb977 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -612,8 +612,8 @@ trait_precedence: ; trait_reference_list: - fully_qualified_class_name { zend_init_list(&$$.u.op.ptr, Z_STRVAL($1.u.constant) TSRMLS_CC); } - | trait_reference_list ',' fully_qualified_class_name { zend_add_to_list(&$1.u.op.ptr, Z_STRVAL($3.u.constant) TSRMLS_CC); $$ = $1; } + fully_qualified_class_name { ulong fetch_type = ZEND_FETCH_CLASS_GLOBAL; zend_resolve_class_name(&$1, &fetch_type, 1 TSRMLS_CC); zend_init_list(&$$.u.op.ptr, Z_STRVAL($1.u.constant) TSRMLS_CC); } + | trait_reference_list ',' fully_qualified_class_name { ulong fetch_type = ZEND_FETCH_CLASS_GLOBAL; zend_resolve_class_name(&$3, &fetch_type, 1 TSRMLS_CC); zend_add_to_list(&$1.u.op.ptr, Z_STRVAL($3.u.constant) TSRMLS_CC); $$ = $1; } ; trait_method_reference: |