rfc:class_properties_initialization
This is an old revision of the document!
Request for Comments: Class properties initialization
- Version: 1.0
- Date: 20010-07-30
- Author: Krzysztof Antczak k.antczak@livedata.pl
- Status: In Draft
- First Published at: http://wiki.php.net/rfc/class_properties_initialization
Introduction
The purpose of this feature is to provide more advanced way to initialize class properties using closures, objects, type hinting.
Why do we need it?
- objects structures - structured objects initialization - like IoC/DI containers, where structure is not a result of code execution, but it's a result of strictly controlled design.
- code readability
Proposal
class Foo { private $var1 = function () { /* some callback ? */ } private $var2 = array ( 'foo' => function () { /* some callback ? */ } ); private httpRequest $var3 = NULL; }
Other / Related
class Foo { private $var1 = new Bar(); private $var2 = Bar :: getInstance (); private $var3 = time (); private httpRequest $var4 = getRequest (); }
Rejected initialization types
private $foo = $this -> someStuff(); // impossible/nonsense (?)
Changelog
2010-07-30 k.antczak Initial RFC creation.
rfc/class_properties_initialization.1280486386.txt.gz · Last modified: 2017/09/22 13:28 (external edit)