rfc:class_properties_initialization
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:class_properties_initialization [2010/07/30 10:43] – k.antczak | rfc:class_properties_initialization [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 5: | Line 5: | ||
* Status: In Draft | * Status: In Draft | ||
* First Published at: http:// | * First Published at: http:// | ||
- | * Related RFC: [[rfc: | + | * Related RFC: [[rfc: |
===== Introduction ===== | ===== Introduction ===== | ||
Line 27: | Line 27: | ||
private httpRequest $var3 = NULL; | private httpRequest $var3 = NULL; | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | instead of: | ||
+ | |||
+ | <code php> | ||
+ | class Foo | ||
+ | { | ||
+ | private $var1; | ||
+ | |||
+ | private $var2; | ||
+ | |||
+ | private $var3 = NULL; | ||
+ | |||
+ | public function __construct () | ||
+ | { | ||
+ | $this -> var1 = function () { /* some callback ? */ } | ||
+ | | ||
+ | $this -> var2 = array ( ' | ||
+ | |||
+ | if ( ( $request = SomeCore :: getRequest () ) instanceof httpRequest ) | ||
+ | { | ||
+ | $this -> var3 = $request; | ||
+ | } | ||
+ | } | ||
} | } | ||
</ | </ | ||
Line 38: | Line 63: | ||
{ | { | ||
private $var1 = new Bar(); | private $var1 = new Bar(); | ||
+ | |||
private $var2 = Bar :: getInstance (); | private $var2 = Bar :: getInstance (); | ||
} | } | ||
Line 47: | Line 73: | ||
class Foo | class Foo | ||
{ | { | ||
- | private $var3 = time (); | + | private $var1 = time (); |
| | ||
- | private httpRequest $var4 = getRequest (); | + | private httpRequest $var2 = getRequest (); |
} | } | ||
</ | </ |
rfc/class_properties_initialization.1280486639.txt.gz · Last modified: 2017/09/22 13:28 (external edit)