ID: 33941 User updated by: gordon at heydon dot com dot au Reported By: gordon at heydon dot com dot au -Status: Feedback +Status: Open Bug Type: Class/Object related Operating System: linux / windows PHP Version: 5.0.4 New Comment:
I have tested this on ubuntu linux using php5-200508012230 to test. Even with the modified prototype I did not have any success. Previous Comments: ------------------------------------------------------------------------ [2005-08-01 12:42:33] stochnagara at hotmail dot com I've tested this with the lastest win32 binary package. The bug is still present. When __get prototype is changed to function & __get everything works fine. ------------------------------------------------------------------------ [2005-08-01 11:53:00] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-08-01 05:48:59] gordon at heydon dot com dot au Description: ------------ If using the __set() and __get() to store and manipulate arrays within a property, if the array is not being stored as an array then the array assignment will not work. If in the example the property just has the value from the assignment stored without the serialization, so storing the array within the array this works. Also the funny thing is that if you put echos within the __set() and __get the $obj->prop[5] = 'apple' does not output anything at all. It is like PHP is trying to guess what the __set() is doing and then doing that, Reproduce code: --------------- <?php class ex { public function __get($prop) { return unserialize($this->fields[$prop]); } public function __set($prop, $value) { $this->fields[$prop] = serialize($value); } private $fields; } $obj = new ex; $obj->prop = array(4 => 'pear'); $obj->prop[5] = 'apple'; var_dump($obj->prop); ?> Expected result: ---------------- array(1) { [4]=> string(4) "pear" [5]=> string(5) "apple" } Actual result: -------------- array(1) { [4]=> string(4) "pear" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33941&edit=1
