Re: RFC: Trait expects interface
| From: | Rowan Tommins | Date: | Fri, 07 Jan 2022 18:56:44 +0000 |
| Subject: | Re: RFC: Trait expects interface | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116849@lists.php.net to get a copy of this message | ||
On 07/01/2022 13:47, Robert Korulczyk wrote:
I'm not really sure why would you not want this - what is the point of marking method as interface implementation, if it is not reflected by type system in actual execution?It's really quite simple: I don't want traits to tell me how I "must" use them, but am quite happy for them to document how I "can" use them. Unless we allow a trait to *automatically* implement the interface (or similar features, such as an interface with default implementation) there is no direct impact on the actual type system. There are, as far as I can see, three things the feature would provide: - Documentation: the trait can tell me as a programmer that it contains everything I need to implement a particular interface - Code generation: the trait can import the list of methods from an interface as abstract methods which it requires - Policing: the trait can force me as a programmer to use it in a certain way; this is the part I don't see the need for Regards, -- Rowan Tommins [IMSoP]