Traits "implements" support
| From: | David Rodrigues | Date: | Thu, 26 Nov 2020 16:50:12 +0000 |
| Subject: | Traits "implements" support | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-112301@lists.php.net to get a copy of this message | ||
Hello!
Now with PHP 8, traits supports abstract functions that should be
implemented by the class that uses this trait.
So is it now possible that traits could have support to implements too? So
when class uses this trait, it will be an implementation of X interface and
will have to implement methods based on it.
interface A {
public function x();
}
trait B implements A {
public function y() { $this->x(); }
// public function x() still not implemented.
}
class Z { // impliticy implements A interface due to B trait.
use B;
public function x() {} // required!
}
Atenciosamente,
David Rodrigues