Re: [RFC] Adding a "Stringable" interface to PHP 8
| From: | Mike Schinkel | Date: | Mon, 27 Jan 2020 19:20:13 +0000 |
| Subject: | Re: [RFC] Adding a "Stringable" interface to PHP 8 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108277@lists.php.net to get a copy of this message | ||
> On Jan 27, 2020, at 10:55 AM, Larry Garfield <larry@garfieldtech.com> wrote:
>
> On Mon, Jan 27, 2020, at 10:19 AM, Nikita Popov wrote:
>> Automatically implementing interfaces based on implemented methods could
>> also be a general language feature (see Go interfaces for example), but
>> likely not one we're interested in having in it's full generality. In this
>> particular case, it seems useful though.
>>
>> Regards,
>> Nikita
>
> I believe Anthony Ferrara proposed "Weak interfaces" once many years ago, which is
> essentially what you're describing. It didn't get much traction although I'm unclear
> why. (Possibly just less familiarity with Go at the time?)
>
> I agree not all interfaces should be implicit, but having implicitly-implementable interfaces
> does sound generally useful. That shouldn't block this RFC, but might this RFC be a model for
> how to implement such things more generically in the future?
>
> --Larry Garfield
Glad to see you picked up on this Larry.
I don't think "Weak Interfaces" became an RFC unless Google is failing me, but I
found a reference to it being on the mailing list from Matthieu Napoli's article on GitHub
about decoupling, which is worth a read:
https://github.com/mnapoli/mnapoli.github.io/blob/master/articles/decoupling-packages.md
As far as Go's implicit interfaces, I have found that to be one of the most compelling language
features of Go, and would be ecstatic if we could find a way to support implicit interfaces in PHP.
-Mike