Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59972 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78290 invoked from network); 15 Apr 2012 22:47:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Apr 2012 22:47:31 -0000 Authentication-Results: pb1.pair.com header.from=simonsimcity@googlemail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=simonsimcity@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: simonsimcity@googlemail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:52531] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/D0-05733-2005B8F4 for ; Sun, 15 Apr 2012 18:47:31 -0400 Received: by obbta17 with SMTP id ta17so5892168obb.29 for ; Sun, 15 Apr 2012 15:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=kjlntNUxdcf4ck3sD1KsYdNRbnVdc5qQp0P6GAML2qs=; b=lsH5lBUhG4nXgYiqQiIcZXOCQi+I5JfYbym4ezirE5sWYwI15wPmdjW3TS52pUg8L3 m/uAIrjO8XdHU8REA3Eeu7HmplJEvOkyhyWo0uwvKp01E0ixYBeSP4FzF3un4bt4Vyt8 3oKZjJ2aGv4VbRed8Jk6sdLyGtTl9JBoELQoNdkVZGwh0+B8BpcEHXrffhGpTFVh7wAI 9BpWdXET/fGnpaFYuhKYsOQh1YrRwploAfVFx0IGvhvx9mwCrAZeRN1RjBGnigiCi0Zd lczmBmAisnyQ1nCsnbuHqF7D8H0fmf5+95wjQSls83YnY/0WHMY8+wXyWgHkCBBDz4Vz DsWw== MIME-Version: 1.0 Received: by 10.60.12.162 with SMTP id z2mr12879516oeb.47.1334530046825; Sun, 15 Apr 2012 15:47:26 -0700 (PDT) Received: by 10.60.98.74 with HTTP; Sun, 15 Apr 2012 15:47:26 -0700 (PDT) In-Reply-To: <01ed01cd19aa$58810e80$09832b80$@alliantinternet.com> References: <01ed01cd19aa$58810e80$09832b80$@alliantinternet.com> Date: Mon, 16 Apr 2012 00:47:26 +0200 Message-ID: To: Dmitri Snytkine Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Ability to assign new object to a class property. From: simonsimcity@googlemail.com (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 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 = new StdClass(); } Sorry if this code contains syntax-errors, but I think you'll still get the point ;) Bye Simon