note 119628 rejected from language.oop5.traits by cmb
| From: | cmb@php.net | Date: | Wed, 20 Jul 2016 10:37:40 +0000 |
| Subject: | note 119628 rejected from language.oop5.traits by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206060@lists.php.net to get a copy of this message | ||
Note Submitter: mik-ek8944 at ya dot ru
----
<?php
trait Hello {
public function sayHello() {
echo 'Hello ';
}
}
trait World {
use Hello;//here the first connection Hello (second in MyHelloWorld )
abstract function sayHello(); //if this line is commentid
/*
FATAL ERROR Trait method sayHello has not been applied, because there are collisions with other
trait methods on MyHelloWorld on line number 18
*/
public function sayWorld() {
$this->sayHello();
echo 'World!';
}
}
class MyHelloWorld {
use Hello, World; //here the second connection Hello (first in World)
}
$o = new MyHelloWorld();
$o->sayWorld(); //Hello World!
?>