On Sat, Jun 17, 2023 at 4:10 PM David Gebler <davidgeb...@gmail.com> wrote:
>
> On Thu, Jun 15, 2023 at 4:48 AM Levi Morrison via internals 
> <internals@lists.php.net> wrote:
>>
>>
>> I am moving my RFC for interface default methods to discussion:
>> https://wiki.php.net/rfc/interface-default-methods.
>>
>
> Can I ask, the RFC doesn't say - does your implementation ensure default 
> implementations can only call other methods which exist on the interface in 
> the same manner as Java? i.e. the following would give some sort of error?
>
> interface A {
>     public function foo(): void {
>         $this->bar();
>     }
> }
>
> class B implements A {
>     public function bar(): void {
>         ...
>     }
> }
>
> But the following would be okay?
>
> interface A {
>     public function foo(): void {
>         $this->bar();
>     }
>
>     public function bar(): void;
> }
>

No, there's no attempt to ensure the method body adheres to calling
the public interface. Due to PHP's possible dynamic behaviors, I don't
think it's reasonable to attempt to enforce it at compile-time. I'm
not sure it's worth the effort trying to enforce it at runtime either,
but it would be nice to see lints from static analysis tools which
detect this issue.

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

Reply via email to