Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22976 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96672 invoked by uid 1010); 26 Apr 2006 19:16:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 96657 invoked from network); 26 Apr 2006 19:16:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Apr 2006 19:16:01 -0000 X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:50868] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 2E/C7-19715-0F6CF444 for ; Wed, 26 Apr 2006 15:16:01 -0400 Received: from localhost (strato.aixcept.de [81.169.182.136]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 6B4D235C1EC; Wed, 26 Apr 2006 21:15:55 +0200 (CEST) Date: Wed, 26 Apr 2006 21:15:37 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <749874265.20060426211537@marcus-boerger.de> To: Jochem Maas Cc: bu@orbitel.bg, php internals In-Reply-To: <444E2108.8050203@iamjochem.com> References: <444E0854.2000804@emini.dk> <200604251602.42837.bu@orbitel.bg> <444E2108.8050203@iamjochem.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Static properties From: helly@php.net (Marcus Boerger) Hello Jochem, Tuesday, April 25, 2006, 3:15:52 PM, you wrote: > 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). Do not mix class based OO like PHP and prototype based OO like JavaScript. > (anyone with the argument that PHP!=Ruby or PHP!=Javascript might consider that > PHP!="the OO paradigm") PHP simply supports its own set and view of OO. > 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? >>> It is just some decision that was taken that the newer OO stuff should be a bit more strict. Best regards, Marcus