Interface Default Methods

Read the RFC
95
168 yes
263 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

The Pipe Operator

The "pipe operator" |> allows you to chain multiple function calls in a more convenient way.

90
262 yes
122 no
new MyClass()->method() without parentheses

Chain method on newly created objects without parentheses

35
46 yes
13 no
Property Hooks

A new way of interacting with properties

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