ID: 38109 User updated by: public at grik dot net Reported By: public at grik dot net Status: Bogus Bug Type: SPL related Operating System: * PHP Version: * Assigned To: helly New Comment:
Thanks, then it's a documentation bug. In the documentation there is no mention that it is about _not_visible_ properties only. http://www.php.net/~helly/php/ext/spl/classArrayObject.html#f4077c9cb0ca99a6fc4d5da841443224 "Array indices can be accessed as properties in read/write." Previous Comments: ------------------------------------------------------------------------ [2006-07-15 09:42:39] [EMAIL PROTECTED] 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 The ",2" in the constructor call means ArrayObject::SPL_ARRAY_ARRAY_AS_PROPS which means use the array as properties if there is no conflict with visible properties. That is in case A) the property len is visible outside hence the property can be used. In case B) the property len is not used so that the array is being used instead. You will see an interesting behavior if you provide a class method in case B that dumps the contents. ------------------------------------------------------------------------ [2006-07-15 02:50:13] public at grik dot net Description: ------------ When I declare a property as "public", it's being ignored. When I declare it as protected or private it is processed and visible from outside of the object. Reproduce code: --------------- A) class Rules extends ArrayObject { public $len; function __construct($array){ parent::__construct($array,2); $this['len'] = 2; } } $x = new Rules(array(1,2)); var_dump($x->len); B) class Rules extends ArrayObject { protected $len; function __construct($array){ parent::__construct($array,2); $this['len'] = 2; } } $x = new Rules(array(1,2)); var_dump($x->len); Expected result: ---------------- A) int(2) B) Fatal error</b>: Cannot access protected property Rules::$len Actual result: -------------- A) NULL B) int(2) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38109&edit=1