#33799 [Opn->Bgs]: Inheriting of ArrayObject causes a strange behaviour
| From: | tony2001@php.net | Date: | Thu, 21 Jul 2005 08:23:46 +0000 |
| Subject: | #33799 [Opn->Bgs]: Inheriting of ArrayObject causes a strange behaviour | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-82254@lists.php.net to get a copy of this message | ||
ID: 33799
Updated by: tony2001@php.net
Reported By: stochnagara at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 5.0.4
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
Previous Comments:
------------------------------------------------------------------------
[2005-07-21 09:34:52] stochnagara at hotmail dot com
Description:
------------
When I extend the ArrayObject class, I cannot override any of the
functions offsetXXX. Also when using var_dump i see only "Array"
element and I don't see my new public property $name.
I suppose the second thing is a bug. But the first one is maybe a
feature that one cannot override internal PHP functions.
Reproduce code:
---------------
<?
class AO2 extends ArrayObject {
public $name;
public function offsetGet ($index) {
echo "Calling offsetGet for index $index\n";
return parent::offsetGet ($index);
}
}
$a = new AO2();
$a->name = "123";
$a[5] = 'Hi';
echo "a[5] = {$a[5]}\n";;
echo "a->name = {$a->name}\n";;
var_dump($a);
?>
Expected result:
----------------
Calling offsetGet for index 5
a[5] = Hi
a->name = 123
object(AO2)#1 (1) {
[5]=>
string(2) "Hi"
["name"]=>
string(3) "123"
}
Actual result:
--------------
a[5] = Hi
a->name = 123
object(AO2)#1 (1) {
[5]=>
string(2) "Hi"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33799&edit=1