Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60005 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16442 invoked from network); 16 Apr 2012 15:29:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Apr 2012 15:29:58 -0000 Authentication-Results: pb1.pair.com header.from=dsnytkine@Ultralogistics.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dsnytkine@Ultralogistics.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain Ultralogistics.com from 64.197.110.172 cause and error) X-PHP-List-Original-Sender: dsnytkine@Ultralogistics.com X-Host-Fingerprint: 64.197.110.172 thrud.alliantinternet.com Received: from [64.197.110.172] ([64.197.110.172:52836] helo=thrud.alliantinternet.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/C8-05733-4FA3C8F4 for ; Mon, 16 Apr 2012 11:29:57 -0400 Received: by thrud.alliantinternet.com (Postfix, from userid 1001) id 5CA83174327; Mon, 16 Apr 2012 11:29:53 -0400 (EDT) To: "'Simon Schick'" Cc: "'PHP Internals'" References: <01ed01cd19aa$58810e80$09832b80$@alliantinternet.com> In-Reply-To: Date: Mon, 16 Apr 2012 11:29:52 -0400 Message-ID: <006601cd1be5$c4795880$4d6c0980$@alliantinternet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thread-Index: Ac0bWdhio2aSOrDlSPKHPINbvPtwXgAi66Bg Content-Language: en-us Subject: RE: [PHP-DEV] Ability to assign new object to a class property. From: dsnytkine@Ultralogistics.com ("Dmitri Snytkine") In my example the property was not static. To make it clear - it cannot be static for this to work. The instance of the class assigned to a property will be created when = the object is created -most likely=20 it will have to be done before the constructor is called so that the = instance of property is available to constructor. Dmitri Snytkine Web Developer Ultra Logistics, Inc. Phone: (888) 220-4640 x 2097 Fax: (888) 795-6642 E-Mail: dsnytkine@ultralogistics.com Web: www.ultralogistics.com "A Top 100 Logistics I.T. Provider in 2011" -----Original Message----- From: Simon Schick [mailto:simonsimcity@googlemail.com]=20 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 > > class MyClass{ > > private $storage =3D 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 created the $storage variable = is > automatically assigned a new ArrayObject. > Somethink like this is valid, possible and commonly used in Java, why = not in > php? > > Has anyone already asked for this to be valid syntax in php? > > Dmitri Snytkine > Web Developer > Ultra Logistics, Inc. > Phone: (888) 220-4640 x 2097 > Fax: (888) 795-6642 > E-Mail: dsnytkine@ultralogistics.com > Web: www.ultralogistics.com > > "A Top 100 Logistics I.T. Provider in 2011" > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Hi, Dmitri Just to add a random thought .... When do you expect this code to be executed? class Foo { static public $foo =3D new StdClass(); } Sorry if this code contains syntax-errors, but I think you'll still get the point ;) Bye Simon --=20 PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php