On Tue, Feb 23, 2016 at 4:48 AM, Chris Riley <t.carn...@gmail.com> wrote:
> This isn't such a great idea as it will cause some of traits functionality > to be broken: I can currently use a trait and alias its methods and change > their visibility. If a trait implements an interface which is copied onto > my class I can no longer do this as the compiler will throw a fatal error > for the class not correctly implementing the interface that got copied from > the trait. > This is only true under Proposal 2 of the RFC, and this is listed as an open issue: https://wiki.php.net/rfc/traits-with-interfaces#proposal_2 Proposal 1, where the engine enforces interface declarations on traits, doesn't affect how traits are inserted and still allows aliasing. > If you decide to continue pursuing this RFC, I'd like to see some thought > given to the above; perhaps it could be as simple as not copying the > interface if aliases/visibility changes are made in the use or perhaps > something more complex which allows specifying which interfaces should be > copied into the class from the trait. > I agree that there are several reasonable solutions here, but I'm not sure which is the best. It does feel too aggressive to have it be a fatal error if aliasing undoes the interface implementation. At the same time, introducing new syntax to enable aliasing to work with interface propagation defeats the purpose, which is to make it easier and simpler to implement an interface via a trait. I'd be interested to hear if you have any ideas about how this should look. I'm mostly unfamiliar with aliasing traits in practice, so I'd be curious to see how this RFC would affect your code. Cheers -- Kevin