Bug #55406 [NEW]: get_object_vars and array casting when extending ArrayObject
| From: | chrisstocktonaz at gmail dot com | Date: | Thu, 11 Aug 2011 19:59:18 +0000 |
| Subject: | Bug #55406 [NEW]: get_object_vars and array casting when extending ArrayObject | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-162522@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.4.0alpha3
Package: SPL related
Bug Type: Bug
Bug description:get_object_vars and array casting when extending ArrayObject
Description:
------------
As discussed on internals mailing list here [1], ArrayObject I think is
overriding
the get_properties handler in a bit to simple of a way. I think the
ArrayObject
should merge the spl hash with the default handler.
[1] http://news.php.net/php.internals/54508
Test script:
---------------
--Code
class TestOne {
public $TestOne_1 = 1;
}
class TestTwo extends ArrayObject {
public $TestTwo_1 = 1;
}
class TestThree extends TestTwo {
public $TestThree_1 = 1;
}
$t1 = new TestOne;
var_dump((array) $t1, get_object_vars($t1));
$t2 = new TestTwo;
var_dump((array) $t2, get_object_vars($t2));
$t3 = new TestThree;
var_dump((array) $t3, get_object_vars($t3));
Expected result:
----------------
array(1) {
["TestOne_1"]=>
int(1)
}
array(1) {
["TestOne_1"]=>
int(1)
}
array(0) {
// TestOne_1
// TestTwo_1
}
array(0) {
// TestOne_1
// TestTwo_1
}
array(0) {
// TestOne_1
// TestTwo_1
// TestThree_1
}
array(0) {
// TestOne_1
// TestTwo_1
// TestThree_1
}
Actual result:
--------------
array(1) {
["TestOne_1"]=>
int(1)
}
array(1) {
["TestOne_1"]=>
int(1)
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
--
Edit bug report at https://bugs.php.net/bug.php?id=55406&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55406&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55406&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55406&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=55406&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55406&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=55406&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=55406&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=55406&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=55406&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=55406&r=support
Expected behavior: https://bugs.php.net/fix.php?id=55406&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=55406&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=55406&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=55406&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55406&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55406&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=55406&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=55406&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=55406&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=55406&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=55406&r=mysqlcfg