felipe Sat, 02 Jul 2011 17:12:20 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=312817
Log: - Fixed bug #55086 (Namespace alias does not work inside trait's use block) patch by: Pierrick Bug: https://bugs.php.net/55086 (Assigned) Namespace alias does not work inside trait's use block Changed paths: A php/php-src/branches/PHP_5_4/Zend/tests/bug55086.phpt U php/php-src/branches/PHP_5_4/Zend/zend_compile.c U php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y A php/php-src/trunk/Zend/tests/bug55086.phpt U php/php-src/trunk/Zend/zend_compile.c U php/php-src/trunk/Zend/zend_language_parser.y Added: php/php-src/branches/PHP_5_4/Zend/tests/bug55086.phpt =================================================================== --- php/php-src/branches/PHP_5_4/Zend/tests/bug55086.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/Zend/tests/bug55086.phpt 2011-07-02 17:12:20 UTC (rev 312817) @@ -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 Modified: php/php-src/branches/PHP_5_4/Zend/zend_compile.c =================================================================== --- php/php-src/branches/PHP_5_4/Zend/zend_compile.c 2011-07-02 16:43:31 UTC (rev 312816) +++ php/php-src/branches/PHP_5_4/Zend/zend_compile.c 2011-07-02 17:12:20 UTC (rev 312817) @@ -4052,6 +4052,8 @@ /* 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 { Modified: php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y =================================================================== --- php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y 2011-07-02 16:43:31 UTC (rev 312816) +++ php/php-src/branches/PHP_5_4/Zend/zend_language_parser.y 2011-07-02 17:12:20 UTC (rev 312817) @@ -612,8 +612,8 @@ ; 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: Added: php/php-src/trunk/Zend/tests/bug55086.phpt =================================================================== --- php/php-src/trunk/Zend/tests/bug55086.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/bug55086.phpt 2011-07-02 17:12:20 UTC (rev 312817) @@ -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 Modified: php/php-src/trunk/Zend/zend_compile.c =================================================================== --- php/php-src/trunk/Zend/zend_compile.c 2011-07-02 16:43:31 UTC (rev 312816) +++ php/php-src/trunk/Zend/zend_compile.c 2011-07-02 17:12:20 UTC (rev 312817) @@ -4052,6 +4052,8 @@ /* 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 { Modified: php/php-src/trunk/Zend/zend_language_parser.y =================================================================== --- php/php-src/trunk/Zend/zend_language_parser.y 2011-07-02 16:43:31 UTC (rev 312816) +++ php/php-src/trunk/Zend/zend_language_parser.y 2011-07-02 17:12:20 UTC (rev 312817) @@ -612,8 +612,8 @@ ; 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:
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php