Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22633 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30484 invoked by uid 1010); 1 Apr 2006 00:49:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 30469 invoked from network); 1 Apr 2006 00:49:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Apr 2006 00:49:19 -0000 X-Host-Fingerprint: 194.109.193.120 unknown Linux 2.5 (sometimes 2.4) (4) Received: from ([194.109.193.120:50699] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 49/8C-28679-E0ECD244 for ; Fri, 31 Mar 2006 19:49:19 -0500 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id 28E491A4DEF for ; Sat, 1 Apr 2006 02:49:16 +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 22786-15 for ; Sat, 1 Apr 2006 02:49:14 +0200 (CEST) Received: from [10.0.13.55] (ip129-15-211-87.adsl2.versatel.nl [87.211.15.129]) by mx1.moulin.nl (Postfix) with ESMTP id 8012A1A4DB9 for ; Sat, 1 Apr 2006 02:49:14 +0200 (CEST) Message-ID: <442DCE06.8070307@iamjochem.com> Date: Sat, 01 Apr 2006 02:49:10 +0200 User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: php internals 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: __set() / __get() : limitation and/or unintentional behavoiur? From: jochem@iamjochem.com (Jochem Maas) 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 array[$key]; } public function __set( $key, $value ) { echo "Setting $key\n"; $this->array[$key] = $value; } } $t = new T; $t->insideArray = array(); // SET 1 $t->insideArray["test"] = "testing!"; // SET 2 var_dump( $t ); ?> OUTPUT: Setting insideArray Getting insideArray object(T)#1 (1) { ["array:private"]=> array(1) { ["insideArray"]=> array(1) { ["test"]=> string(8) "testing!" } }