Re: [VOTE] Interface Default Methods

From: Date: Mon, 03 Jul 2023 11:50:41 +0000
Subject: Re: [VOTE] Interface Default Methods
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-120734@lists.php.net to get a copy of this message
Le 03/07/2023 à 13:32, Michał Marcin Brzuchalski a écrit :
I voted "yes", my personal use case waits for this feature. My use case example: https://gist.github.com/brzuchal/89e9481bbd34a6ce3d95a68eabff038b With interface default methods I'd no longer need traits that implement a single or in rare cases 2 methods that use their respective methods returning objects and iterate in Generator fashion over a paginated result set. This is not an issue if there is one implementation of the interface but when I decorate to apply some: * caching * logging * failover then the trait has to be attached to every class besides that it has to exist which is an additional symbol here. Cheers, Michał Marcin Brzuchalski
Please everyone yes to this ! I use Symfony daily, and the SomethingAwareInterface / SomethingAwareTrait is very annoying, by having default method implementations on interfaces, it would remove the use of having traits at all. Everything would be much easier to read and write. LoggerAwareInterface would no longer require us to use LoggerAwareTrait on every class, etc... This is kind of sugar candy I'd really love. Best regards, -- Pierre

« previous php.internals (#120734) next »