Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @created 09.01.2018
- * @author Smiley <smiley@chillerlan.net>
- * @copyright 2018 Smiley
- * @license MIT
- */
- namespace Example;
- interface A {
- public function log(string $message):A;
- public function doStuff():A;
- }
- interface B {
- public function log(string $message):B;
- public function doOtherStuff():B;
- }
- trait Log{
- public function log(string $message){
- echo $message.PHP_EOL;
- return $this;
- }
- }
- class ClassA implements A{
- use Log{
- log as _log;
- }
- public function log(string $message):A{
- return $this->_log($message);
- }
- public function doStuff():A{
- return $this;
- }
- }
- // proposal
- class ClassB implements B{
- use Log{
- log as log:B; // a new return type
- }
- public function doOtherStuff():B{
- return $this;
- }
- }
Add Comment
Please, Sign In to add comment