com php-src: Fixed bug #61998 (Using traits with method aliases appears to result in crash during execution): Zend/tests/traits/bug61998.phpt
| From: | Dmitry Stogov | Date: | Mon, 21 May 2012 08:53:21 +0000 |
| Subject: | com php-src: Fixed bug #61998 (Using traits with method aliases appears to result in crash during execution): Zend/tests/traits/bug61998.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-69122@lists.php.net to get a copy of this message | ||
Commit: 7632a32ef94be48c8d4f37bbca7cde458fbf20b9
Author: Dmitry Stogov <dmitry@zend.com> Mon, 21 May 2012 12:53:21 +0400
Parents: f3615bc6f7079e8e9c8940a80b011de1e01951d3
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7632a32ef94be48c8d4f37bbca7cde458fbf20b9
Log:
Fixed bug #61998 (Using traits with method aliases appears to result in crash during execution)
Bugs:
https://bugs.php.net/61998
Changed paths:
A Zend/tests/traits/bug61998..phpt
Diff:
diff --git a/Zend/tests/traits/bug61998.phpt b/Zend/tests/traits/bug61998.phpt
new file mode 100644
index 0000000..612caa0
--- /dev/null
+++ b/Zend/tests/traits/bug61998.phpt
@@ -0,0 +1,68 @@
+--TEST--
+Bug #61998 (Using traits with method aliases appears to result in crash during execution)
+--FILE--
+<?php
+class Foo {
+ use T1 {
+ func as newFunc;
+ }
+
+ public function func() {
+ echo "From Foo\n";
+ }
+}
+
+trait T1 {
+ public function func() {
+ echo "From T1\n";
+ }
+}
+
+class Bar {
+ public function func() {
+ echo "From Bar\n";
+ }
+ public function func2() {
+ echo "From Bar\n";
+ }
+ public function func3() {
+ echo "From Bar\n";
+ }
+ use T1 {
+ func as newFunc;
+ func as func2;
+ }
+ use T2 {
+ func2 as newFunc2;
+ func2 as newFunc3;
+ func2 as func3;
+ }
+}
+
+trait T2 {
+ public function func2() {
+ echo "From T2\n";
+ }
+}
+
+$f = new Foo();
+
+$f->newFunc(); //from T1
+$f->func(); //from Foo
+
+$b = new Bar();
+$b->newFunc(); //from T1
+$b->func(); //from Bar
+$b->func2(); //from Bar
+$b->newFunc2(); //from T2
+$b->newFunc3(); //from T2
+$b->func3(); //from Bar
+--EXPECTF--
+From T1
+From Foo
+From T1
+From Bar
+From Bar
+From T2
+From T2
+From Bar