Independent but related to
I wrote an RFC about porting Dart-like Automatic Property Initialization to PHP. Nikic was so generous to provide an initial PoC for it (since I don't do C):
I am proposing this for inclusion in 5.6. There is no BC breaks afaik.
The RFC suggests to allow for $this->foo as Constructor arguments to make the boilerplate code for property assignments in constructors superfluous. This is the core feature subject to discussion.
I've spoken to about two dozen developers outside internals prior to suggesting this RFC and the general response was positive and the core feature unanimously deemed useful. Moreover, in the previous discussion about constructor promotion there was some messages suggesting that the now proposed syntactic approach is more preferred than using visibility keywords.
The RFC also suggests some related syntactic sugar like Methodless Constructors, an alternate and shorter syntax, as well as making this available in the entire class scope. These are things I am not sure of so I am hoping for comments on these. Should this RFC get into the voting phase, we should by then have either promoted or eliminated these options through discussion.
Thanks and Regards, Gordon
2013/9/27 Gordon Oheim [email protected]
Quoted text · 7 lines
Independent but related to
I wrote an RFC about porting Dart-like Automatic Property Initialization to PHP. Nikic was so generous to provide an initial PoC for it (since I don't do C):
- https://wiki.php.net/rfc/**automatic_property_**initializationhttps://wiki.php.net/rfc/automatic_property_initialization
- https://github.com/php/php-**src/pull/474https://github.com/php/php-src/pull/474
I am proposing this for inclusion in 5.6. There is no BC breaks afaik.
The RFC suggests to allow for $this->foo as Constructor arguments to make the boilerplate code for property assignments in constructors superfluous. This is the core feature subject to discussion.
I simply don't like it to have a concrete method without body. Either abstract without body, or concrete with body. In this case it would mean to have an empty body
public function __construct ($this->x) {}
but I think that wouldn't be too bad :)
Quoted text · 4 lines
I've spoken to about two dozen developers outside internals prior to suggesting this RFC and the general response was positive and the core feature unanimously deemed useful. Moreover, in the previous discussion about constructor promotion there was some messages suggesting that the now proposed syntactic approach is more preferred than using visibility keywords.
The RFC also suggests some related syntactic sugar like Methodless Constructors, an alternate and shorter syntax, as well as making this available in the entire class scope. These are things I am not sure of so I am hoping for comments on these. Should this RFC get into the voting phase, we should by then have either promoted or eliminated these options through discussion.
Thanks and Regards, Gordon
--
Hi,
big +1 from my side. Would love to see this functionality in 5.6.
Thanks for the proposal, Gordon.
Cheers,
Toby
--
Helping people to create high quality web apps http://qafoo.com Tobias Schlitt http://schlitt.info GPG Key: 0xC462BC14
I think this is a great proposal. Anything that reduces code verbosity, increases programmer productivity, improves readability and doesn't bloat PHP gets my support.
--
Andrea Faulds
http://ajf.me/