#29184 [Com]: Fatal error when trying to set an object property an array

From: Date: Fri, 03 Sep 2004 22:58:15 +0000
Subject: #29184 [Com]: Fatal error when trying to set an object property an array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-65706@lists.php.net to get a copy of this message
ID: 29184 Comment by: jcrawford at codebowl dot com Reported By: jbeall at heraldic dot us Status: Open Bug Type: Zend Engine 2 problem Operating System: Linux PHP Version: 5.0.0 New Comment: I am using the latest version of PHP and i have the same results when i try to do this. array_push($object->property, $myarray); this is not my expected results Previous Comments: ------------------------------------------------------------------------ [2004-07-15 14:52:56] jbeall at heraldic dot us Description: ------------ Trying to assigned a specific array index of an object property, when __set() been defined and will catch the __set() call, causes a fatal error. This is similar to bug 28444. That bug has the same error, but the code that produces it is different. Reproduce code: --------------- class Sub { function __get($prop) { echo "Property $prop called\n"; } function __set($prop, $val) { echo "Property $prop set to $val\n"; } } $foo = new Sub(); $foo->someProp[0] = 'apple'; echo $foo->someProp[0]; Expected result: ---------------- apple Actual result: -------------- Fatal error: Cannot access undefined property for object with overloaded property access in test.php on line 18 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29184&edit=1

« previous php.bugs (#65706) next »