summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/tests/traits/bugs/abstract-methods01.phpt19
-rw-r--r--Zend/tests/traits/bugs/abstract-methods02.phpt26
-rw-r--r--Zend/tests/traits/bugs/abstract-methods03.phpt22
-rw-r--r--Zend/tests/traits/bugs/abstract-methods04.phpt36
-rw-r--r--Zend/tests/traits/bugs/alias-semantics.phpt23
-rw-r--r--Zend/tests/traits/bugs/case-sensitive.phpt25
-rw-r--r--Zend/tests/traits/bugs/interfaces.phpt19
-rw-r--r--Zend/tests/traits/bugs/missing-trait.phpt15
-rw-r--r--Zend/tests/traits/bugs/overridding-conflicting-methods.phpt31
-rw-r--r--Zend/tests/traits/conflict001.phpt25
-rw-r--r--Zend/tests/traits/conflict002.phpt32
-rw-r--r--Zend/tests/traits/conflict003.phpt33
-rw-r--r--Zend/tests/traits/flattening001.phpt42
-rw-r--r--Zend/tests/traits/flattening002.phpt28
-rw-r--r--Zend/tests/traits/flattening003.phpt32
-rw-r--r--Zend/tests/traits/inheritance001.phpt24
-rw-r--r--Zend/tests/traits/inheritance002.phpt27
-rw-r--r--Zend/tests/traits/inheritance003.phpt38
-rw-r--r--Zend/tests/traits/language001.phpt21
-rw-r--r--Zend/tests/traits/language002.phpt32
-rw-r--r--Zend/tests/traits/language003.phpt29
-rw-r--r--Zend/tests/traits/language004.phpt31
-rw-r--r--Zend/tests/traits/language005.phpt40
-rw-r--r--Zend/tests/traits/language006.phpt31
-rw-r--r--Zend/tests/traits/language007.phpt30
-rw-r--r--Zend/tests/traits/language008a.phpt23
-rw-r--r--Zend/tests/traits/language008b.phpt30
-rw-r--r--Zend/tests/traits/language009.phpt36
-rw-r--r--Zend/tests/traits/language010.phpt32
-rw-r--r--Zend/tests/traits/language011.phpt34
30 files changed, 866 insertions, 0 deletions
diff --git a/Zend/tests/traits/bugs/abstract-methods01.phpt b/Zend/tests/traits/bugs/abstract-methods01.phpt
new file mode 100644
index 0000000000..6275caa193
--- /dev/null
+++ b/Zend/tests/traits/bugs/abstract-methods01.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Abstract Trait Methods should behave like common abstract methods.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello {
+ public abstract function hello();
+}
+
+class TraitsTest {
+ use THello;
+}
+
+$test = new TraitsTest();
+$test->hello();
+?>
+--EXPECTF--
+Fatal error: Class %s contains %d abstract method and must therefore be declared abstract or implement the remaining methods (%s) in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/abstract-methods02.phpt b/Zend/tests/traits/bugs/abstract-methods02.phpt
new file mode 100644
index 0000000000..78abe7d1bc
--- /dev/null
+++ b/Zend/tests/traits/bugs/abstract-methods02.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Abstract Trait Methods should behave like common abstract methods.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello {
+ public abstract function hello();
+}
+
+trait THelloImpl {
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+class TraitsTest {
+ use THello;
+ use THelloImpl;
+}
+
+$test = new TraitsTest();
+$test->hello();
+?>
+--EXPECTF--
+Hello \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/abstract-methods03.phpt b/Zend/tests/traits/bugs/abstract-methods03.phpt
new file mode 100644
index 0000000000..605b1d8e9e
--- /dev/null
+++ b/Zend/tests/traits/bugs/abstract-methods03.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Abstract Trait Methods should behave like common abstract methods.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello {
+ public abstract function hello();
+}
+
+class TraitsTest {
+ use THello;
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+$test = new TraitsTest();
+$test->hello();
+?>
+--EXPECTF--
+Hello \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/abstract-methods04.phpt b/Zend/tests/traits/bugs/abstract-methods04.phpt
new file mode 100644
index 0000000000..56a3464067
--- /dev/null
+++ b/Zend/tests/traits/bugs/abstract-methods04.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Abstract Trait Methods should behave like common abstract methods and
+implementstion may be provided by other traits. Sorting order shouldn't influence result.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello {
+ public abstract function hello();
+}
+
+trait THelloImpl {
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+class TraitsTest1 {
+ use THello;
+ use THelloImpl;
+}
+
+$test = new TraitsTest1();
+$test->hello();
+
+class TraitsTest2 {
+ use THelloImpl;
+ use THello;
+}
+
+$test = new TraitsTest2();
+$test->hello();
+
+?>
+--EXPECTF--
+HelloHello \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/alias-semantics.phpt b/Zend/tests/traits/bugs/alias-semantics.phpt
new file mode 100644
index 0000000000..ac86692880
--- /dev/null
+++ b/Zend/tests/traits/bugs/alias-semantics.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Semantic of alias operation is to provide an additional identifier for the method body of the original method.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello {
+ public function a() {
+ echo 'A';
+ }
+}
+
+class TraitsTest {
+ use THello { a as b; }
+}
+
+$test = new TraitsTest();
+$test->a();
+$test->b();
+
+?>
+--EXPECTF--
+AA \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/case-sensitive.phpt b/Zend/tests/traits/bugs/case-sensitive.phpt
new file mode 100644
index 0000000000..1d7b77a0c4
--- /dev/null
+++ b/Zend/tests/traits/bugs/case-sensitive.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Check for problems with case sensitivity in compositions
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait A {
+ public function M1() {}
+ public function M2() {}
+}
+
+trait B {
+ public function M1() {}
+ public function M2() {}
+}
+
+class MyClass {
+ use A;
+ use B;
+}
+?>
+--EXPECTF--
+Warning: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
+
+Warning: Trait method M2 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/interfaces.phpt b/Zend/tests/traits/bugs/interfaces.phpt
new file mode 100644
index 0000000000..486bda7efb
--- /dev/null
+++ b/Zend/tests/traits/bugs/interfaces.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Make sure trait does not implement an interface.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+interface MyInterface {
+ public function a();
+}
+
+trait THello implements MyInterface {
+ public function a() {
+ echo 'A';
+ }
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use 'MyInterface' as interface on 'THello' since it is a Trait in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/missing-trait.phpt b/Zend/tests/traits/bugs/missing-trait.phpt
new file mode 100644
index 0000000000..ce4fa5c69a
--- /dev/null
+++ b/Zend/tests/traits/bugs/missing-trait.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check error message for missing traits
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+class TraitsTest {
+ use THello;
+}
+
+$test = new TraitsTest();
+
+?>
+--EXPECTF--
+Fatal error: Trait 'THello' not found in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt b/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt
new file mode 100644
index 0000000000..fc09a367bd
--- /dev/null
+++ b/Zend/tests/traits/bugs/overridding-conflicting-methods.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Overridding Conflicting Methods should not result in a notice/warning about collisions
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello1 {
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+trait THello2 {
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+class TraitsTest {
+ use THello1;
+ use THello2;
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+$test = new TraitsTest();
+$test->hello();
+?>
+--EXPECTF--
+Hello \ No newline at end of file
diff --git a/Zend/tests/traits/conflict001.phpt b/Zend/tests/traits/conflict001.phpt
new file mode 100644
index 0000000000..a129b63dae
--- /dev/null
+++ b/Zend/tests/traits/conflict001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Method conflict in traits
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello1 {
+ private function hello() {
+ echo 'Hello';
+ }
+}
+
+trait THello2 {
+ private function hello() {
+ echo 'Hello';
+ }
+}
+
+class TraitsTest {
+ use THello1;
+ use THello2;
+}
+?>
+--EXPECTF--
+Warning: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/conflict002.phpt b/Zend/tests/traits/conflict002.phpt
new file mode 100644
index 0000000000..64712d40a4
--- /dev/null
+++ b/Zend/tests/traits/conflict002.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Overwridden methods do not cause a conflict.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait HelloWorld {
+ public function sayHello() {
+ echo 'Hello World!';
+ }
+}
+
+trait HelloWorld2 {
+ public function sayHello() {
+ echo 'Hello World2!';
+ }
+}
+
+
+class TheWorldIsNotEnough {
+ use HelloWorld;
+ use HelloWorld2;
+ public function sayHello() {
+ echo 'Hello Universe!';
+ }
+}
+
+$o = new TheWorldIsNotEnough();
+$o->sayHello(); // echos Hello Universe!
+?>
+--EXPECTF--
+Hello Universe! \ No newline at end of file
diff --git a/Zend/tests/traits/conflict003.phpt b/Zend/tests/traits/conflict003.phpt
new file mode 100644
index 0000000000..5a6d9cf915
--- /dev/null
+++ b/Zend/tests/traits/conflict003.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Two methods resulting in a conflict, should be reported both.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait A {
+ public function smallTalk() {
+ echo 'a';
+ }
+ public function bigTalk() {
+ echo 'A';
+ }
+}
+
+trait B {
+ public function smallTalk() {
+ echo 'b';
+ }
+ public function bigTalk() {
+ echo 'B';
+ }
+}
+
+class Talker {
+ use A, B;
+}
+
+?>
+--EXPECTF--
+Warning: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d
+
+Warning: Trait method bigTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/flattening001.phpt b/Zend/tests/traits/flattening001.phpt
new file mode 100644
index 0000000000..aa7f03dcb8
--- /dev/null
+++ b/Zend/tests/traits/flattening001.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Methods using object properties
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait T1 {
+ public function getText() {
+ return $this->text;
+ }
+}
+
+trait T2 {
+ public function setTextT2($val) {
+ $this->text = $val;
+ }
+}
+
+class TraitsTest {
+ use T1;
+ use T2;
+ private $text = 'test';
+ public function setText($val) {
+ $this->text = $val;
+ }
+}
+
+$o = new TraitsTest();
+var_dump($o->getText());
+
+$o->setText('foo');
+
+var_dump($o->getText());
+
+$o->setText('bar');
+
+var_dump($o->getText());
+?>
+--EXPECTF--
+string(4) "test"
+string(3) "foo"
+string(3) "bar" \ No newline at end of file
diff --git a/Zend/tests/traits/flattening002.phpt b/Zend/tests/traits/flattening002.phpt
new file mode 100644
index 0000000000..251af29711
--- /dev/null
+++ b/Zend/tests/traits/flattening002.phpt
@@ -0,0 +1,28 @@
+--TEST--
+parent:: works like in a method defined without traits.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+class Base {
+ public function sayHello() {
+ echo 'Hello ';
+ }
+}
+
+trait SayWorld {
+ public function sayHello() {
+ parent::sayHello();
+ echo 'World!';
+ }
+}
+
+class MyHelloWorld extends Base {
+ use SayWorld;
+}
+
+$o = new MyHelloWorld();
+$o->sayHello();
+?>
+--EXPECTF--
+Hello World! \ No newline at end of file
diff --git a/Zend/tests/traits/flattening003.phpt b/Zend/tests/traits/flattening003.phpt
new file mode 100644
index 0000000000..d189ca70c1
--- /dev/null
+++ b/Zend/tests/traits/flattening003.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Traits are flattened recurivly.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function sayHello() {
+ echo 'Hello ';
+ }
+}
+
+trait World {
+ public function sayWorld() {
+ echo 'World!';
+ }
+}
+
+trait HelloWorld {
+ use Hello, World;
+}
+
+class MyHelloWorld {
+ use HelloWorld;
+}
+
+$o = new MyHelloWorld();
+$o->sayHello();
+$o->sayWorld();
+?>
+--EXPECTF--
+Hello World! \ No newline at end of file
diff --git a/Zend/tests/traits/inheritance001.phpt b/Zend/tests/traits/inheritance001.phpt
new file mode 100644
index 0000000000..e8195c4749
--- /dev/null
+++ b/Zend/tests/traits/inheritance001.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Trait method overwridden by a method defined in the class.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait HelloWorld {
+ public function sayHello() {
+ echo 'Hello World!';
+ }
+}
+
+class TheWorldIsNotEnough {
+ use HelloWorld;
+ public function sayHello() {
+ echo 'Hello Universe!';
+ }
+}
+
+$o = new TheWorldIsNotEnough();
+$o->sayHello(); // echos Hello Universe!
+?>
+--EXPECTF--
+Hello Universe! \ No newline at end of file
diff --git a/Zend/tests/traits/inheritance002.phpt b/Zend/tests/traits/inheritance002.phpt
new file mode 100644
index 0000000000..51badc5a4c
--- /dev/null
+++ b/Zend/tests/traits/inheritance002.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Trait method overriddes base class method
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+class Base {
+ public function sayHello() {
+ echo 'Hello ';
+ }
+}
+
+trait SayWorld {
+ public function sayHello() {
+ echo 'World!';
+ }
+}
+
+class MyHelloWorld extends Base {
+ use SayWorld;
+}
+
+$o = new MyHelloWorld();
+$o->sayHello();
+?>
+--EXPECTF--
+World! \ No newline at end of file
diff --git a/Zend/tests/traits/inheritance003.phpt b/Zend/tests/traits/inheritance003.phpt
new file mode 100644
index 0000000000..ba2e4da76d
--- /dev/null
+++ b/Zend/tests/traits/inheritance003.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Trait method overriddes base class method and satisfies prototype
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+abstract class Base {
+ public abstract function sayHello(array $a);
+}
+
+class SubClass extends Base {
+ public function sayHello(array $a) {
+ echo "World!\n";
+ }
+}
+
+$s = new SubClass();
+$s->sayHello(array());
+
+
+trait SayWorld {
+ public function sayHello(Base $d) {
+ echo 'World!';
+ }
+}
+
+class MyHelloWorld extends Base {
+ use SayWorld;
+}
+
+$o = new MyHelloWorld();
+$o->sayHello(array());
+
+?>
+--EXPECTF--
+World!
+
+Fatal error: Declaration of MyHelloWorld::sayHello() must be compatible with that of Base::sayHello() in %s on line %d
diff --git a/Zend/tests/traits/language001.phpt b/Zend/tests/traits/language001.phpt
new file mode 100644
index 0000000000..d892112416
--- /dev/null
+++ b/Zend/tests/traits/language001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Single Trait with simple trait method
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait THello {
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+class TraitsTest {
+ use THello;
+}
+
+$test = new TraitsTest();
+$test->hello();
+?>
+--EXPECTF--
+Hello
diff --git a/Zend/tests/traits/language002.phpt b/Zend/tests/traits/language002.phpt
new file mode 100644
index 0000000000..d093f2952d
--- /dev/null
+++ b/Zend/tests/traits/language002.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Use multiple traits.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function sayHello() {
+ echo 'Hello ';
+ }
+}
+
+trait World {
+ public function sayWorld() {
+ echo 'World';
+ }
+}
+
+class MyHelloWorld {
+ use Hello, World;
+ public function sayExclamationMark() {
+ echo '!';
+ }
+}
+
+$o = new MyHelloWorld();
+$o->sayHello();
+$o->sayWorld();
+$o->sayExclamationMark();
+?>
+--EXPECTF--
+Hello World! \ No newline at end of file
diff --git a/Zend/tests/traits/language003.phpt b/Zend/tests/traits/language003.phpt
new file mode 100644
index 0000000000..716dda8518
--- /dev/null
+++ b/Zend/tests/traits/language003.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Use instead to solve a conflict.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function saySomething() {
+ echo 'Hello';
+ }
+}
+
+trait World {
+ public function saySomething() {
+ echo 'World';
+ }
+}
+
+class MyHelloWorld {
+ use Hello, World {
+ Hello::saySomething instead World;
+ }
+}
+
+$o = new MyHelloWorld();
+$o->saySomething();
+?>
+--EXPECTF--
+Hello \ No newline at end of file
diff --git a/Zend/tests/traits/language004.phpt b/Zend/tests/traits/language004.phpt
new file mode 100644
index 0000000000..ed176dc2a7
--- /dev/null
+++ b/Zend/tests/traits/language004.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Use instead to solve a conflict and as to access the method.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function saySomething() {
+ echo 'Hello';
+ }
+}
+
+trait World {
+ public function saySomething() {
+ echo ' World';
+ }
+}
+
+class MyHelloWorld {
+ use Hello, World {
+ Hello::saySomething instead World;
+ World::saySomething as sayWorld;
+ }
+}
+
+$o = new MyHelloWorld();
+$o->saySomething();
+$o->sayWorld();
+?>
+--EXPECTF--
+Hello World \ No newline at end of file
diff --git a/Zend/tests/traits/language005.phpt b/Zend/tests/traits/language005.phpt
new file mode 100644
index 0000000000..5ee7ab0079
--- /dev/null
+++ b/Zend/tests/traits/language005.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Use instead to solve a conflict and as to access the method.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait A {
+ public function smallTalk() {
+ echo 'a';
+ }
+ public function bigTalk() {
+ echo 'A';
+ }
+}
+
+trait B {
+ public function smallTalk() {
+ echo 'b';
+ }
+ public function bigTalk() {
+ echo 'B';
+ }
+}
+
+class Talker {
+ use A, B {
+ B::smallTalk instead A;
+ A::bigTalk instead B;
+ B::bigTalk as talk;
+ }
+}
+
+$t = new Talker;
+$t->smallTalk();
+$t->bigTalk();
+$t->talk();
+
+?>
+--EXPECTF--
+bAB \ No newline at end of file
diff --git a/Zend/tests/traits/language006.phpt b/Zend/tests/traits/language006.phpt
new file mode 100644
index 0000000000..5a32359bb5
--- /dev/null
+++ b/Zend/tests/traits/language006.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Express requirements of a trait by abstract methods.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function sayHelloWorld() {
+ echo 'Hello'.$this->getWorld();
+ }
+ abstract public function getWorld();
+ }
+
+class MyHelloWorld {
+ private $world;
+ use Hello;
+ public function getWorld() {
+ return $this->world;
+ }
+ public function setWorld($val) {
+ $this->world = $val;
+ }
+}
+
+$o = new MyHelloWorld();
+$o->setWorld(' World!');
+$o->sayHelloWorld();
+
+?>
+--EXPECTF--
+Hello World! \ No newline at end of file
diff --git a/Zend/tests/traits/language007.phpt b/Zend/tests/traits/language007.phpt
new file mode 100644
index 0000000000..3b65d0123a
--- /dev/null
+++ b/Zend/tests/traits/language007.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Traits can fulfill the requirements of abstract base classes.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+abstract class Base {
+ abstract function sayWorld();
+}
+
+trait Hello {
+ public function sayHello() {
+ echo 'Hello';
+ }
+ public function sayWorld() {
+ echo ' World!';
+ }
+ }
+
+class MyHelloWorld extends Base {
+ use Hello;
+}
+
+$o = new MyHelloWorld();
+$o->sayHello();
+$o->sayWorld();
+
+?>
+--EXPECTF--
+Hello World! \ No newline at end of file
diff --git a/Zend/tests/traits/language008a.phpt b/Zend/tests/traits/language008a.phpt
new file mode 100644
index 0000000000..5a12a4e74b
--- /dev/null
+++ b/Zend/tests/traits/language008a.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Visibility can be changed with the as aliasing construct as well.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait HelloWorld {
+ public function sayHello() {
+ echo 'Hello World!';
+ }
+}
+
+class MyClass {
+ use HelloWorld { sayHello as protected; }
+}
+
+
+$o = new MyClass;
+$o->sayHello();
+
+?>
+--EXPECTF--
+Fatal error: Call to protected method MyClass::sayHello() from context '' in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/language008b.phpt b/Zend/tests/traits/language008b.phpt
new file mode 100644
index 0000000000..9abbdbeb0d
--- /dev/null
+++ b/Zend/tests/traits/language008b.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Visibility can be changed with the as aliasing construct as well.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait HelloWorld {
+ public function sayHello() {
+ echo 'Hello World!';
+ }
+}
+
+class MyClass {
+ use HelloWorld { sayHello as private sayHelloWorld; }
+
+ public function callPrivateAlias() {
+ $this->sayHelloWorld();
+ }
+}
+
+$o = new MyClass();
+$o->sayHello();
+$o->callPrivateAlias();
+$o->sayHelloWorld();
+
+
+?>
+--EXPECTF--
+Hello World!Hello World!
+Fatal error: Call to private method MyClass::sayHelloWorld() from context '' in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/language009.phpt b/Zend/tests/traits/language009.phpt
new file mode 100644
index 0000000000..23462e5c17
--- /dev/null
+++ b/Zend/tests/traits/language009.phpt
@@ -0,0 +1,36 @@
+--TEST--
+In instead definitions all trait whose methods are meant to be hidden can be listed.
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait A {
+ public function foo() {
+ echo 'a';
+ }
+}
+
+trait B {
+ public function foo() {
+ echo 'b';
+ }
+}
+
+trait C {
+ public function foo() {
+ echo 'c';
+ }
+}
+
+class Foo {
+ use C, A, B {
+ B::foo instead A, C;
+ }
+}
+
+$t = new Foo;
+$t->foo();
+
+?>
+--EXPECTF--
+b \ No newline at end of file
diff --git a/Zend/tests/traits/language010.phpt b/Zend/tests/traits/language010.phpt
new file mode 100644
index 0000000000..f184457bef
--- /dev/null
+++ b/Zend/tests/traits/language010.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Aliasing leading to conflict should result in error message
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function hello() {
+ echo 'Hello';
+ }
+}
+
+trait World {
+ public function world() {
+ echo ' World!';
+ }
+}
+
+
+class MyClass {
+ use Hello, World { hello as world; }
+}
+
+$o = new MyClass();
+$o->hello();
+$o->world();
+
+?>
+--EXPECTF--
+Warning: Trait method world has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
+Hello
+Fatal error: Call to undefined method MyClass::world() in %s on line %d \ No newline at end of file
diff --git a/Zend/tests/traits/language011.phpt b/Zend/tests/traits/language011.phpt
new file mode 100644
index 0000000000..8c4b1a489a
--- /dev/null
+++ b/Zend/tests/traits/language011.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Aliasing leading to conflict should result in error message
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+trait Hello {
+ public function sayHello() {
+ echo 'Hello';
+ }
+}
+
+trait World {
+ public function sayHello() {
+ echo ' World!';
+ }
+}
+
+
+class MyClass {
+ use Hello, World { sayHello as sayWorld; }
+}
+
+$o = new MyClass();
+$o->sayHello();
+$o->sayWorld();
+
+?>
+--EXPECTF--
+Warning: Trait method sayWorld has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
+
+Warning: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
+
+Fatal error: Call to undefined method MyClass::sayHello() in %s on line %d \ No newline at end of file