#33799 [NEW]: Inheriting of ArrayObject causes a strange behaviour
| From: | stochnagara at hotmail dot com | Date: | Thu, 21 Jul 2005 07:34:53 +0000 |
| Subject: | #33799 [NEW]: Inheriting of ArrayObject causes a strange behaviour | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-82248@lists.php.net to get a copy of this message | ||
From: stochnagara at hotmail dot com
Operating system: Windows XP
PHP version: 5.0.4
PHP Bug Type: Class/Object related
Bug description: Inheriting of ArrayObject causes a strange behaviour
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 bug report at http://bugs.php.net/?id=33799&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33799&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33799&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33799&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33799&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33799&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33799&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33799&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33799&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33799&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33799&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=33799&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=33799&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33799&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33799&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33799&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33799&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33799&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33799&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33799&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33799&r=mysqlcfg