maz's avatar

Matthias Brendel

maz

Member since

325

Total Reputation

2

Total Arguments

9

Total Votes for Arguments

Arguments and votes

5

C#-inspired properties, yes please!

Share:
Read the RFC: Property Hooks yassine avatar
yassine
voted yes
27

This is good to have.

Properties are useful for exchanging (reading and writing) single values. Properties are good for data binding, etc.

With this RFC we can implement:

  • Validation
  • Trigger events
  • Call methods if there is more to do

Update: About the $field I am not sure. Having a separate backing field can have some advantages.

Share:
Read the RFC: Property Hooks maz avatar
maz
voted yes
1

I think this is very useful for PHP library developers.

They can add methods and provide a default implementation without breaking code (and if they only throw an exception). For example Doctrine could add a addAll method to the Collection interface and provide a basic implementation that uses the existing add method under the hood.

Since interfaces (in other programming languages) don't add member fields, the this won't need to be adjusted (by an offset) and the interface default methods just get added to the virtual method table (vtable) of the class, if they are not implemented by the class.

Share:
Read the RFC: Interface Default Methods maz avatar
maz
voted yes
2

A lot of posts point out that JavaScript's syntax matches what's proposed here. If PHP remains a hold-out by not adding this syntax, it feeds the reputation that PHP is always behind the curve.

Marketability aside, i get sick of writing anonymous functions with use () statements where i need to make changes to an imported variable, and thus have to import by-reference. It's clunky, especially when references are so frowned-upon. To me it's much cleaner to have a short-closure where i know all data in scope remains in the same scope of that function.

Share:
Read the RFC: Short Closures 2.0 thookerov avatar
thookerov
voted yes
2

I never understood the limit of one statement in the short arrow function syntax.

This seems to fix it and put arrow functions back on the level of the standard anonymous function.

Share:
Read the RFC: Short Closures 2.0 agc avatar
agc
voted yes
2

So many times I had to drop array_map/reduce or similar functions just because I didn't want to use "classic" closure syntax. Honestly, I don't even see a big need in having the "classic" syntax nowadays, but having a multiline new-style closure looks very logical to me.

Share:
Read the RFC: Short Closures 2.0 ozahorulia avatar
ozahorulia
voted yes
2

Prevents having to add a trait to every class that has to implement an interface, being able to provide default implementations via interfaces would be a large DX improvment

Share:
Read the RFC: Interface Default Methods sandermuller avatar
sandermuller
voted yes
2

Most of the time when creating an Interface that shares some implementation we would always create Interface + Trait. This is just more work. With Interface default methods we would get rid of the Trait and be able to have it in the interface already!

Share:
Read the RFC: Interface Default Methods wendell_adriel avatar
wendell_adriel
voted yes
2

it's works great in other languages like java and kotlin.

Share:
Read the RFC: Interface Default Methods jeidison avatar
jeidison
voted yes
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!