Interface Default Methods

Read the RFC
95
168 yes
264 no

Interface Default Methods improves backwards compatibility when changing interfaces, but also add a way to have multi-inheritance in PHP.

Click the bar to cast your vote!
39%
61%
1

Multiple inheritance is probably a better solution. It's something that already exists in other languages and which we can certainly reimplement using their same solutions to the same problems (e.g. conflicting methods and properties). The functionality would then be more powerful and complete than this RFC.

Share:
sukei avatar
sukei
voted no
1

..a controversial one indeed. Personally I would try to avoid this feature in my own code (just like I avoid traits and abstract classes because I feel that they are a sign of bad abstractions).

To me the fact that convinced me is the last section of the RFC:

This feature may be used to enhance existing interfaces in PHP. Countable could add function isEmpty(): bool { return $this->count() == 0; }. Iterator could add methods like map, filter, and reduce which behave similarly to array_map, array_filter, and array_reduce.

Share:
bastian avatar
bastian
voted yes
1

Implementing an interface is different than extending an abstract class

Share:
remivasco avatar
remivasco
voted no
1

Interface MUST be just declaration and NO implementation at all

Share:
ksn135 avatar
ksn135
voted no
1

Its an interface is a contract. It should have no behavior.

Share:
german avatar
german
voted no
1

Interfaces should not have specific implementations, but define specifications.

Share:
liu avatar
liu
voted no
1

It feels like an anti-pattern, we still have traits to fix this kind of thing. Multi-inheritance is not possible unfortunately, but an interface should not be misused for this.

Share:
buismaarten avatar
buismaarten
voted no
1

Having traits does not mean default methods in interfaces should no longer be allowed.

Share:
zois avatar
zois
voted yes
1

Interface = declaration Class = functionality

Share:
darren avatar
darren
voted no
1

Interfaces should remain as defining the structure and the contract.

Share:
kegan avatar
kegan
voted no
1

Keep interfaces to be interfaces!

Share:
przemyslaw avatar
przemyslaw
voted no
1

This RFC could be useful if in PHP there was no inheritance and traits. But PHP has both traits and inheritance so this should be used.

Share:
raszekster avatar
raszekster
voted no
1

Whether it's:

  • Default interface methods
  • Traits with interfaces
  • True multi-inheritance I would like to see some form of this implemented.
Share:
jim avatar
jim
voted yes
1

Separation of what and how. Besides this, it could pave the way for https://en.wikipedia.org/wiki/Multiple_inheritance which is also undesirable

Share:
koen avatar
koen
voted no
1

I personally don't need it right now but I guess it could be useful to people, since other languages have it

Share:
rastusik avatar
rastusik
voted yes

Check out another RFCs

Property Hooks

A new way of interacting with properties

70
141 yes
90 no
Short Closures 2.0

This RFC proposes a way to have multi-line short closures — closures that don't need explicit use statements, but can still have multiple lines and a return statement.

101
373 yes
66 no
Asymmetric Visibility v2

A new syntax for declaring the “set” operation visibility of an object property

19
16 yes
40 no
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!