note 112058 deleted from language.oop5.traits by cmb
| From: | cmb@php.net | Date: | Tue, 08 Sep 2015 19:44:27 +0000 |
| Subject: | note 112058 deleted from language.oop5.traits by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-203739@lists.php.net to get a copy of this message | ||
Note Submitter: syzer3 at gmail dot com
----
Traits can be useful to create Fluent API
ex:
trait StaticMake
{
public static function make()
{
return new static();
}
}
class HelloWorld
{
use StaticMake;
public function getHello()
{
return "Hello World";
}
}
//now instead:
$theHello = new HelloWorld;
echo $theHello -> getHello();
//one may just use
echo HelloWorld:make() -> getHello();