Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22957 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55320 invoked by uid 1010); 25 Apr 2006 13:16:08 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 55295 invoked from network); 25 Apr 2006 13:16:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2006 13:16:07 -0000 X-PHP-List-Original-Sender: jochem@iamjochem.com X-Host-Fingerprint: 194.109.193.120 unknown Linux 2.5 (sometimes 2.4) (4) Received: from ([194.109.193.120:45064] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id D4/04-19715-3112E444 for ; Tue, 25 Apr 2006 09:16:04 -0400 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id 0C8721B9179; Tue, 25 Apr 2006 15:16:01 +0200 (CEST) Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (moulin [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30533-01; Tue, 25 Apr 2006 15:15:58 +0200 (CEST) Received: from [192.168.1.118] (bspr.xs4all.nl [194.109.161.228]) by mx1.moulin.nl (Postfix) with ESMTP id 61B43188313; Tue, 25 Apr 2006 15:15:58 +0200 (CEST) Message-ID: <444E2108.8050203@iamjochem.com> Date: Tue, 25 Apr 2006 15:15:52 +0200 User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: bu@orbitel.bg CC: php internals References: <444E0854.2000804@emini.dk> <200604251602.42837.bu@orbitel.bg> In-Reply-To: <200604251602.42837.bu@orbitel.bg> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at moulin.nl Subject: Re: [PHP-DEV] Static properties From: jochem@iamjochem.com (Jochem Maas) Petar Nedyalkov wrote: > On Tuesday 25 April 2006 14:30, Edin Kadribasic wrote: > >>Hi, >> >>I was wondering if someone could enlighten me why it is not possible to >>create on-the-fly static properties: >> >>php -r 'class foo{}; foo::$bar = 1;' >>Fatal error: Access to undeclared static property: foo::$bar in Command >>line code on line 1 > > > This totally breaks the capsulation in the OO paradigm, so I find it the right > behaviour. Taking apart the fact that there's no compilation in PHP, it also > prevents capsulation and making a member variable of an object available only > after it's declaration in the class (except for stdClass) is correct for me. > I see this as "You can't redefine the model at runtime". Rubys allows exactly that and I'm sure your not going to say that Ruby is not an OO language - Javascript likewise, in that it allows runtime definition/extension of the model (granted it's prototype based rather than class based). (anyone with the argument that PHP!=Ruby or PHP!=Javascript might consider that PHP!="the OO paradigm") I don't think the Fatal Error mentioned above is, from a endusers' POV, what would be expected given the ability to define non-static properties on the fly... If I had to guess as to what kind of error was raised I would have put my money on E_STRICT - i.e. 'we don't recommend this way of doing things, but it doesn't hurt the engine per se' having said that I have never needed to define static properties on the fly, so it's all rather academic. :-) > > >>Was this not possible because of the engine implementation of the static >>properties? >> >>Edin > >