Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-19 Thread Arvids Godjuks
I have to agree with Richard as a user-land developer. It looks nice, but knowing how people can twist things I don't think I would like this feature get implemented. It just add stuff that is crazy to debug. Consider someone adds a property and initializes a user-land object. That object has othe

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-18 Thread Richard Lynch
On Sun, April 15, 2012 5:47 pm, Simon Schick wrote: > Just to add a random thought > When do you expect this code to be executed? > > class Foo { > static public $foo = new StdClass(); > } I may be too late to this party, but... For what it's worth, if the non-scalar initialization in cl

RE: [PHP-DEV] Ability to assign new object to a class property.

2012-04-16 Thread Dmitri Snytkine
mon Schick [mailto:simonsimc...@googlemail.com] Sent: Sunday, April 15, 2012 6:47 PM To: Dmitri Snytkine Cc: PHP Internals Subject: Re: [PHP-DEV] Ability to assign new object to a class property. 2012/4/13 Dmitri Snytkine : > I always wondered why can't we do something like this in php > > cl

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-15 Thread Simon Schick
2012/4/13 Dmitri Snytkine : > I always wondered why can't we do something like this in php > > class MyClass{ > > private $storage = new ArrayObject(); > > public function __construct($v){ > // whatever > } > > // rest of class > > } > > Why can't we create a new object and assign it to property li

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-14 Thread Stas Malyshev
Hi! > It's convenient to assign an empty array to a property in this manner. > > private $storage = array(); > > So why not > private $storage = new ArrayObject(); array is a static constant. Objects have complex behavior. So it's better to handle this in ctor. I see no value in splitting ctor

RE: [PHP-DEV] Ability to assign new object to a class property.

2012-04-14 Thread Dmitri Snytkine
PM To: Anthony Ferrara Cc: Dmitri Snytkine; PHP Internals Subject: Re: [PHP-DEV] Ability to assign new object to a class property. Hi! > Just throwing this out there, but that code wouldn't be run on parse. > It would be "queued" to run prior to the constructor on instantiation

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Stas Malyshev
Hi! > Just throwing this out there, but that code wouldn't be run on parse. > It would be "queued" to run prior to the constructor on instantiation. Why? You have perfectly good ctor, why not use it? -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext.

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Anthony Ferrara
Stas, > Because the engine doesn't run code when parsing class definitions so > defaults should be constants (otherwise would also create a lot of > trouble for bytecode caching as object are not cacheable). Just throwing this out there, but that code wouldn't be run on parse. It would be "queued

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Stas Malyshev
Hi! > Why can't we create a new object and assign it to property like this? Because the engine doesn't run code when parsing class definitions so defaults should be constants (otherwise would also create a lot of trouble for bytecode caching as object are not cacheable). Use ctor for complex ini

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Etienne Kneuss
11" > > > -Original Message- > From: ekne...@gmail.com [mailto:ekne...@gmail.com] On Behalf Of Etienne Kneuss > Sent: Friday, April 13, 2012 3:27 PM > To: Dmitri Snytkine > Cc: PHP Internals > Subject: Re: [PHP-DEV] Ability to assign new object to a class prope

RE: [PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Dmitri Snytkine
DEV] Ability to assign new object to a class property. Hi, On Fri, Apr 13, 2012 at 21:19, Dmitri Snytkine wrote: > I always wondered why can't we do something like this in php > > class MyClass{ > > private $storage = new ArrayObject(); > > public function __construct($v

Re: [PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Etienne Kneuss
Hi, On Fri, Apr 13, 2012 at 21:19, Dmitri Snytkine wrote: > I always wondered why can't we do something like this in php > > class MyClass{ > > private $storage = new ArrayObject(); > > public function __construct($v){ > // whatever > } > > // rest of class > > } > > Why can't we create a new obj

[PHP-DEV] Ability to assign new object to a class property.

2012-04-13 Thread Dmitri Snytkine
I always wondered why can't we do something like this in php class MyClass{ private $storage = new ArrayObject(); public function __construct($v){ // whatever } // rest of class } Why can't we create a new object and assign it to property like this? Then when a new instance of MyClass is cr