Edit report at http://bugs.php.net/bug.php?id=51591&edit=1
ID: 51591 Updated by: m...@php.net Reported by: amcsi at mailbox dot hu Summary: No warnings reported when invalidly adding automatically indexed array element -Status: Open +Status: Bogus Type: Bug Package: Unknown/Other Function Operating System: Ubuntu 10.04 beta 2 PHP Version: 5.3.2 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is not a set operation on the object, but rather setting an array entry on the property "bar". Previous Comments: ------------------------------------------------------------------------ [2010-04-18 21:04:31] amcsi at mailbox dot hu Description: ------------ When an object with a __set() method has its non-existent array containing variable set by empty bracket syntax, it just creates a new object variable for the array, as if __set() weren't even there. Test script: --------------- <?php class Foo { public $_vars = array(); public function __set($var, $value) { $this->_vars[$var] = $value; } } $foo = new Foo; $foo->bar[] = 'value'; var_dump($foo); ?> Expected result: ---------------- __set() method called object(Foo)#1 (1) { ["_vars"]=> array(1) { ["bar"]=> array(1) { [0]=> string(5) "value" } } } OR <br /> <b>Fatal error</b>: Cannot use [] for reading in <b>/home/amcsi/htdocs/lol.php</b> on line <b>11</b><br /> Actual result: -------------- object(Foo)#1 (2) { ["_vars"]=> array(0) { } ["bar"]=> array(1) { [0]=> string(5) "value" } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51591&edit=1