#38370 [Com]: __set not triggered when overloading with array (related: #24608)

From: Date: Sun, 13 Aug 2006 10:43:02 +0000
Subject: #38370 [Com]: __set not triggered when overloading with array (related: #24608)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100730@lists.php.net to get a copy of this message
ID: 38370 Comment by: anything at trash-mail dot de Reported By: phpbug at trash-mail dot de Status: Feedback Bug Type: Class/Object related Operating System: Windows XP PHP Version: 5.1.4 New Comment: <?php class Example { protected $arr; // meant to be an array public function __get( $property ) { echo( "Getter for <strong>\$$property</strong> involved when trying to assign an array element." ); } public function __set( $property, $value ) { echo( 'Setter involved.' ); // never executed! } } $example =& new Example; $example->arr['test'] = 'any value'; ?> Previous Comments: ------------------------------------------------------------------------ [2006-08-08 12:00:20] tony2001@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-08-07 22:02:07] phpbug at trash-mail dot de Description: ------------ This issue is related to #24608. ---quote of stas@php.net: I have fixed it to give an error in this case and not to do things which it is not supposed to do. --- No error is given if a __get method is defined. Reproduce code: --------------- $obj->dataarray['field']='...'; /* results in a call to $obj->__get('dataarray') */ Expected result: ---------------- $obj->__get() should be enabled to receive arrays. Otherwise the docs should clearly discuss this limitation and recommend an alternative procedure for overloading properties of type array. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38370&edit=1

« previous php.bugs (#100730) next »