On 2 March 2018 01:38:37 GMT+00:00, "Pedro Magalhães" <m...@pmmaga.net> wrote:
>On Thu, Mar 1, 2018 at 11:04 PM, Rowan Collins
><rowan.coll...@gmail.com>
>wrote:
>>
>> What *can* break an interface's contract is changing the *visibility*
>of
>> the pasted method using "as protected" or "as private". This would
>need to
>> be captured somehow while composing the class, probably producing a
>> compile-time error, just as an explicit "implements" declaration
>would.
>
>
>To add to that, the receiving class can simply replace the trait
>method.

True. This feels closer to normal interface / inheritance checks though: you've 
explicitly written a method that violates the contract not used a 
trait-specific syntax or feature to do so.


>Currently, not even an abstract method on a trait enforces anything on
>the
>receiving class. See: https://bugs.php.net/bug.php?id=75449

The way I see it, the Trait in this proposal isn't enforcing anything, it's 
just pasting in the "implements Foo" clause along with the extra methods. 
Whether the result is valid is up to the receiving class, and there's a 
completely separate requirement that the Trait itself matches the contract.


>With that said, I have started some work on "Implicit Interfaces".

I'm not sure I like the sound of this, but I'll leave that to its own thread.

Regards,

-- 
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to