Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22635 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41057 invoked by uid 1010); 1 Apr 2006 07:05:43 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 41042 invoked from network); 1 Apr 2006 07:05:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2006 07:05:43 -0000 X-Host-Fingerprint: 69.231.221.162 adsl-69-231-221-162.dsl.irvnca.pacbell.net Received: from ([69.231.221.162:18871] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id E8/26-28679-6462E244 for ; Sat, 01 Apr 2006 02:05:42 -0500 Message-ID: To: internals@lists.php.net Date: Fri, 31 Mar 2006 23:05:56 -0800 User-Agent: Thunderbird 1.5 (Windows/20051229) MIME-Version: 1.0 References: <442DCE06.8070307@iamjochem.com> In-Reply-To: <442DCE06.8070307@iamjochem.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 69.231.221.162 Subject: Re: __set() / __get() : limitation and/or unintentional behavoiur? From: unknown@simplemachines.org ("Unknown W. Brackets") The __set() method is called when a property of a class is set, __get() when a property is retrieved. An array is simple a way of listing things; the array itself is a piece of data. When you set a key in that array, you are not setting the array. It may help to think of it like this: $t = new T; $t->insideClass = new T; $t->insideClass->test = "testing!"; In this case, should __set() be called for both lines? Or only for the first? An array is exactly the same, except you cannot define a __set() method on it. Anyway, I don't think this question belongs in internals, imho. -[Unknown] -------- Original Message -------- > I ran the following code on 5.0.4 and 5.1.0 with identical results... > > Could someone shed light one whether the observed behaviour is > intentional and/or correct? > > I expected that one of the following would occur (which obviously > doesn't :-): > > 1. the line commented with 'SET 2' would trigger a > call to __set() (which should fail?). > > 2. the key "test" would be set in the array returned > by __get() but not it the relevant array stored in > $this->array["insideArray"]. > > The reason I question whether what si observed below is wanted behaviour is > because I thought the __set() functionality was there to be able > to protect/control what stuffed into an object ... but apparently it's > rather easy to side step. > > tia, > Jochem