Change the order of properties used for var_dump(), serialize(), comparison, etc.

Now properties are ordered according to their layout in zend_object structure.
This commit is contained in:
Dmitry Stogov 2021-02-26 19:27:55 +03:00
parent b86dfb0e74
commit 72c3ededed
35 changed files with 305 additions and 317 deletions

View File

@ -57,12 +57,12 @@ array(3) {
}
Child::__construct
array(3) {
["Baz"]=>
int(4)
["Foo"]=>
int(1)
["Bar"]=>
int(2)
["Baz"]=>
int(4)
}
array(1) {
["Foo"]=>

View File

@ -32,14 +32,14 @@ var_dump($b);
?>
--EXPECTF--
object(SubclassA)#%d (2) {
["hello":"SubclassA":private]=>
int(0)
["hello":"BaseWithPropA":private]=>
int(0)
["hello":"SubclassA":private]=>
int(0)
}
object(SubclassB)#%d (2) {
["hello":"SubclassB":private]=>
int(0)
["hello":"BaseWithTPropB":private]=>
int(0)
["hello":"SubclassB":private]=>
int(0)
}

View File

@ -45,14 +45,14 @@ NULL
NULL
NULL
object(c)#1 (6) {
["prop1"]=>
int(1)
["prop2":protected]=>
int(2)
["prop3":"a":private]=>
int(3)
["prop4":"a":private]=>
int(4)
["prop1"]=>
int(1)
["prop2":protected]=>
int(2)
["prop5"]=>
int(5)
["prop6"]=>

View File

@ -33,10 +33,10 @@ echo "\n";
?>
--EXPECT--
array (
'' . "\0" . 'B' . "\0" . 'priv' => 4,
'pub' => 1,
'' . "\0" . '*' . "\0" . 'prot' => 2,
'' . "\0" . 'A' . "\0" . 'priv' => 3,
'' . "\0" . 'B' . "\0" . 'priv' => 4,
'dyn' => 5,
6 => 6,
)

View File

@ -24,5 +24,5 @@ print_r($a, true);
var_dump($a < $b);
?>
--EXPECT--
bool(false)
bool(false)
bool(true)
bool(true)

View File

@ -42,20 +42,20 @@ var_dump($b);
?>
--EXPECT--
object(SubclassClassicInheritance)#1 (2) {
["hello":"SubclassClassicInheritance":private]=>
int(0)
["hello":"BaseWithPropA":private]=>
int(0)
["hello":"SubclassClassicInheritance":private]=>
int(0)
}
object(SubclassA)#2 (2) {
["hello":"SubclassA":private]=>
int(0)
["hello":"BaseWithPropA":private]=>
int(0)
["hello":"SubclassA":private]=>
int(0)
}
object(SubclassB)#3 (2) {
["hello":"SubclassB":private]=>
int(0)
["hello":"BaseWithTPropB":private]=>
int(0)
["hello":"SubclassB":private]=>
int(0)
}

View File

@ -63,41 +63,24 @@ ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */
if (!zobj->properties) {
zend_property_info *prop_info;
zend_class_entry *ce = zobj->ce;
uint32_t flags = 0;
int i;
zobj->properties = zend_new_array(ce->default_properties_count);
if (ce->default_properties_count) {
zend_hash_real_init_mixed(zobj->properties);
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
if (!(prop_info->flags & ZEND_ACC_STATIC)) {
flags |= prop_info->flags;
for (i = 0; i < ce->default_properties_count; i++) {
prop_info = ce->properties_info_table[i];
if (UNEXPECTED(Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) == IS_UNDEF)) {
HT_FLAGS(zobj->properties) |= HASH_FLAG_HAS_EMPTY_IND;
}
_zend_hash_append_ind(zobj->properties, prop_info->name,
OBJ_PROP(zobj, prop_info->offset));
if (!prop_info) {
continue;
}
} ZEND_HASH_FOREACH_END();
if (flags & ZEND_ACC_CHANGED) {
while (ce->parent && ce->parent->default_properties_count) {
ce = ce->parent;
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
if (prop_info->ce == ce &&
!(prop_info->flags & ZEND_ACC_STATIC) &&
(prop_info->flags & ZEND_ACC_PRIVATE)) {
zval zv;
if (UNEXPECTED(Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) == IS_UNDEF)) {
HT_FLAGS(zobj->properties) |= HASH_FLAG_HAS_EMPTY_IND;
}
ZVAL_INDIRECT(&zv, OBJ_PROP(zobj, prop_info->offset));
zend_hash_add(zobj->properties, prop_info->name, &zv);
}
} ZEND_HASH_FOREACH_END();
if (UNEXPECTED(Z_TYPE_P(OBJ_PROP(zobj, prop_info->offset)) == IS_UNDEF)) {
HT_FLAGS(zobj->properties) |= HASH_FLAG_HAS_EMPTY_IND;
}
_zend_hash_append_ind(zobj->properties, prop_info->name,
OBJ_PROP(zobj, prop_info->offset));
}
}
}
@ -1555,6 +1538,7 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
}
if (!zobj1->properties && !zobj2->properties) {
zend_property_info *info;
int i;
if (!zobj1->ce->default_properties_count) {
return 0;
@ -1570,14 +1554,18 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
}
Z_PROTECT_RECURSION_P(o1);
ZEND_HASH_FOREACH_PTR(&zobj1->ce->properties_info, info) {
zval *p1 = OBJ_PROP(zobj1, info->offset);
zval *p2 = OBJ_PROP(zobj2, info->offset);
for (i = 0; i < zobj1->ce->default_properties_count; i++) {
zval *p1, *p2;
if (info->flags & ZEND_ACC_STATIC) {
info = zobj1->ce->properties_info_table[i];
if (!info) {
continue;
}
p1 = OBJ_PROP(zobj1, info->offset);
p2 = OBJ_PROP(zobj2, info->offset);
if (Z_TYPE_P(p1) != IS_UNDEF) {
if (Z_TYPE_P(p2) != IS_UNDEF) {
int ret;
@ -1597,7 +1585,7 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
return 1;
}
}
} ZEND_HASH_FOREACH_END();
}
Z_UNPROTECT_RECURSION_P(o1);
return 0;

View File

@ -51,28 +51,28 @@ object(DateTimeZoneExt1)#%d (4) {
string(13) "Europe/London"
}
object(DateTimeZoneExt2)#%d (6) {
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["property1"]=>
int(99)
["property2"]=>
string(5) "Hello"
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/London"
}
object(DateTimeZoneExt2)#%d (6) {
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["property1"]=>
int(99)
["property2"]=>
string(5) "Hello"
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["timezone_type"]=>
int(3)
["timezone"]=>

View File

@ -55,14 +55,14 @@ object(DateTimeExt1)#%d (5) {
string(3) "GMT"
}
object(DateTimeExt2)#%d (7) {
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["property1"]=>
int(99)
["property2"]=>
string(5) "Hello"
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["date"]=>
string(26) "2009-02-03 12:34:41.000000"
["timezone_type"]=>
@ -71,14 +71,14 @@ object(DateTimeExt2)#%d (7) {
string(3) "GMT"
}
object(DateTimeExt2)#%d (7) {
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["property1"]=>
int(99)
["property2"]=>
string(5) "Hello"
["property3"]=>
bool(true)
["property4"]=>
float(10.5)
["date"]=>
string(26) "2009-02-03 12:34:41.000000"
["timezone_type"]=>

View File

@ -30,6 +30,8 @@ object(DOMException)#%d (%d) {
string(23) "Hierarchy Request Error"
["string":"Exception":private]=>
string(0) ""
["code"]=>
int(3)
["file":protected]=>
string(%d) "%sdom003.php"
["line":protected]=>
@ -57,8 +59,6 @@ object(DOMException)#%d (%d) {
}
["previous":"Exception":private]=>
NULL
["code"]=>
int(3)
}
--- Don't catch exception with try/catch

View File

@ -40,6 +40,8 @@ object(DOMException)#%d (7) {
string(20) "Wrong Document Error"
["string":"Exception":private]=>
string(0) ""
["code"]=>
int(4)
["file":protected]=>
string(%d) "%sdom_set_attr_node.php"
["line":protected]=>
@ -67,6 +69,4 @@ object(DOMException)#%d (7) {
}
["previous":"Exception":private]=>
NULL
["code"]=>
int(4)
}

View File

@ -291,23 +291,23 @@ string(1) "a"
reference, object, forward declaration...
int(1)
object(bar)#%d (2) {
["bar"]=>
&string(1) "a"
["foo"]=>
&string(1) "a"
["bar"]=>
&string(1) "a"
}
string(1) "a"
references, object, private...
int(1)
string(1) "a"
object(mega_bar)#5 (4) {
["foo"]=>
&string(1) "a"
["bar"]=>
&string(1) "a"
[%s]=>
&int(1)
["id_ref"]=>
&int(1)
["bar"]=>
&string(1) "a"
["foo"]=>
&string(1) "a"
}
done!

View File

@ -114,40 +114,40 @@ TestDerived::__construct(2,3)
array(3) {
[0]=>
object(TestDerived)#%d (5) {
["row":protected]=>
int(0)
["id"]=>
string(1) "1"
["val":protected]=>
string(1) "A"
["val2":"TestBase":private]=>
NULL
["row":protected]=>
int(0)
["val2"]=>
string(2) "AA"
}
[1]=>
object(TestDerived)#%d (5) {
["row":protected]=>
int(1)
["id"]=>
string(1) "2"
["val":protected]=>
string(1) "B"
["val2":"TestBase":private]=>
NULL
["row":protected]=>
int(1)
["val2"]=>
string(2) "BB"
}
[2]=>
object(TestDerived)#%d (5) {
["row":protected]=>
int(2)
["id"]=>
string(1) "3"
["val":protected]=>
string(1) "C"
["val2":"TestBase":private]=>
NULL
["row":protected]=>
int(2)
["val2"]=>
string(2) "CC"
}

View File

@ -206,9 +206,9 @@ array(4) {
===INSERT===
TestBase::serialize() = 'a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
TestDerived::serialize()
TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}'
TestDerived::serialize()
TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}'
===DATA===
array(4) {
[0]=>
@ -216,9 +216,9 @@ array(4) {
[1]=>
string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
[2]=>
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
[3]=>
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
}
===FAILURE===
Exception:SQLSTATE[HY000]: General error: cannot unserialize class
@ -238,22 +238,22 @@ array(3) {
["name"]=>
string(11) "TestDerived"
["val"]=>
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
}
[2]=>
array(2) {
["name"]=>
NULL
["val"]=>
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
}
}
===FETCHCLASS===
TestBase::unserialize(a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
TestDerived::unserialize()
TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";})
TestDerived::unserialize()
TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:7:"BasePri";s:7:"Private";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";})
array(3) {
[0]=>
object(TestBase)#%d (3) {
@ -270,14 +270,14 @@ array(3) {
string(14) "#DerivedPublic"
["BasePro":protected]=>
string(17) "#DerivdeProtected"
["BasePri":"TestBase":private]=>
string(8) "#Private"
["DerivedPub"]=>
string(7) "#Public"
["DerivedPro":protected]=>
string(10) "#Protected"
["DerivedPri":"TestDerived":private]=>
string(7) "Private"
["BasePri":"TestBase":private]=>
string(8) "#Private"
}
[2]=>
object(TestLeaf)#%d (6) {
@ -285,13 +285,13 @@ array(3) {
string(14) "#DerivedPublic"
["BasePro":protected]=>
string(17) "#DerivdeProtected"
["BasePri":"TestBase":private]=>
string(8) "#Private"
["DerivedPub"]=>
string(7) "#Public"
["DerivedPro":protected]=>
string(10) "#Protected"
["DerivedPri":"TestDerived":private]=>
string(7) "Private"
["BasePri":"TestBase":private]=>
string(8) "#Private"
}
}

View File

@ -95,10 +95,10 @@ PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
object(PDOStatementX)#%d (3) {
["test1"]=>
int(1)
["queryString"]=>
string(24) "SELECT val, id FROM test"
["test1"]=>
int(1)
["test2"]=>
int(22)
}

View File

@ -49,6 +49,6 @@ print_r($client->f());
--EXPECT--
B Object
(
[y] => 6
[x] => 5
[y] => 6
)

View File

@ -235,25 +235,25 @@ array(2) {
array(2) {
[0]=>
object(Child_test1)#%d (4) {
["member2"]=>
int(102)
["member1"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
["member2"]=>
int(102)
}
[1]=>
object(Child_test1)#%d (4) {
["member2"]=>
int(102)
["member1"]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
["member2"]=>
int(102)
}
}
-- Iteration 4 --
@ -281,25 +281,25 @@ array(2) {
array(2) {
[0]=>
object(Child_test2)#%d (4) {
["member1":"Child_test2":private]=>
int(102)
["member1":"Test2":private]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
["member1":"Test2":private]=>
int(100)
["member1":"Child_test2":private]=>
int(102)
}
[1]=>
object(Child_test2)#%d (4) {
["member1":"Child_test2":private]=>
int(102)
["member1":"Test2":private]=>
int(100)
["var1"]=>
int(30)
["var2"]=>
int(101)
["member1":"Test2":private]=>
int(100)
["member1":"Child_test2":private]=>
int(102)
}
}
-- Iteration 6 --
@ -369,25 +369,25 @@ array(2) {
array(2) {
[0]=>
object(Child_test4)#%d (4) {
["var1"]=>
int(103)
["member1"]=>
int(100)
["member2":"Test4":private]=>
int(101)
["member3":protected]=>
int(102)
["var1"]=>
int(103)
}
[1]=>
object(Child_test4)#%d (4) {
["var1"]=>
int(103)
["member1"]=>
int(100)
["member2":"Test4":private]=>
int(101)
["member3":protected]=>
int(102)
["var1"]=>
int(103)
}
}
-- Iteration 10 --

View File

@ -105,10 +105,10 @@ array(5) {
}
[2]=>
object(ChildClass)#%d (2) {
["var3":"ChildClass":private]=>
NULL
["var2":protected]=>
int(5)
["var3":"ChildClass":private]=>
NULL
}
[3]=>
object(FinalClass)#%d (1) {
@ -130,10 +130,10 @@ array(5) {
}
[2]=>
object(ChildClass)#%d (2) {
["var3":"ChildClass":private]=>
NULL
["var2":protected]=>
int(5)
["var3":"ChildClass":private]=>
NULL
}
[3]=>
object(FinalClass)#%d (1) {

View File

@ -173,10 +173,10 @@ int(5)
array(5) {
[0]=>
object(ChildClass)#%d (2) {
["var3":"ChildClass":private]=>
NULL
["var2":protected]=>
int(5)
["var3":"ChildClass":private]=>
NULL
}
["f"]=>
string(5) "first"
@ -191,10 +191,10 @@ int(7)
array(7) {
[0]=>
object(ChildClass)#%d (2) {
["var3":"ChildClass":private]=>
NULL
["var2":protected]=>
int(5)
["var3":"ChildClass":private]=>
NULL
}
[1]=>
string(5) "hello"

View File

@ -146,31 +146,31 @@ bool(true)
array(4) {
[2]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(15)
["pub_value"]=>
NULL
["child_value"]=>
int(15)
}
[0]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(20)
["pub_value"]=>
NULL
["child_value"]=>
int(20)
}
[1]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(500)
["pub_value"]=>
NULL
["child_value"]=>
int(500)
}
[3]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(700)
["pub_value"]=>
NULL
["child_value"]=>
int(700)
}
}
Done

View File

@ -129,30 +129,30 @@ bool(true)
array(4) {
[0]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(15)
["pub_value"]=>
NULL
["child_value"]=>
int(15)
}
[1]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(20)
["pub_value"]=>
NULL
["child_value"]=>
int(20)
}
[2]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(500)
["pub_value"]=>
NULL
["child_value"]=>
int(500)
}
[3]=>
object(ChildClass)#%d (2) {
["child_value"]=>
int(700)
["pub_value"]=>
NULL
["child_value"]=>
int(700)
}
}

View File

@ -84,12 +84,12 @@ array(2) {
---( Superclass: )---
A::test
array(3) {
["hiddenPriv"]=>
string(13) "A::hiddenPriv"
["prot"]=>
string(7) "B::prot"
["pub"]=>
string(6) "B::pub"
["hiddenPriv"]=>
string(13) "A::hiddenPriv"
}
---( Unrelated class: )---

View File

@ -48,10 +48,10 @@ array(4) {
---( Superclass: )---
A::testA
array(3) {
["hiddenPriv"]=>
string(13) "A::hiddenPriv"
["prot"]=>
string(7) "B::prot"
["pub"]=>
string(6) "B::pub"
["hiddenPriv"]=>
string(13) "A::hiddenPriv"
}

View File

@ -41,16 +41,16 @@ var_dump(unserialize($s));
--EXPECT--
string(63) "O:1:"B":2:{i:0;a:1:{i:0;O:8:"stdClass":0:{}}i:1;a:1:{i:0;r:3;}}"
object(B)#3 (2) {
["data2":"B":private]=>
array(1) {
[0]=>
object(stdClass)#4 (0) {
}
}
["data":"A":private]=>
array(1) {
[0]=>
object(stdClass)#4 (0) {
}
}
["data2":"B":private]=>
array(1) {
[0]=>
object(stdClass)#4 (0) {
}
}
}

View File

@ -25,6 +25,6 @@ print_r($u);
--EXPECT--
Derived Object
(
[id:protected] => 44
[id:Base:private] => 64
[id:protected] => 44
)

View File

@ -97,35 +97,35 @@ Sanity check: bool(true)
Before serialization:
object(B)#%d (6) {
["BPriv":"B":private]=>
string(7) "B.BPriv"
["BProt":protected]=>
string(7) "B.BProt"
["BPub"]=>
string(6) "B.BPub"
["APriv":"A":private]=>
string(7) "A.APriv"
["AProt":protected]=>
string(7) "A.AProt"
["APub"]=>
string(6) "A.APub"
["BPriv":"B":private]=>
string(7) "B.BPriv"
["BProt":protected]=>
string(7) "B.BProt"
["BPub"]=>
string(6) "B.BPub"
}
Serialized form:
string(184) "O:1:"B":6:{s:8:"\0B\0BPriv";s:7:"B.BPriv";s:8:"\0*\0BProt";s:7:"B.BProt";s:4:"BPub";s:6:"B.BPub";s:8:"\0A\0APriv";s:7:"A.APriv";s:8:"\0*\0AProt";s:7:"A.AProt";s:4:"APub";s:6:"A.APub";}"
string(184) "O:1:"B":6:{s:8:"\0A\0APriv";s:7:"A.APriv";s:8:"\0*\0AProt";s:7:"A.AProt";s:4:"APub";s:6:"A.APub";s:8:"\0B\0BPriv";s:7:"B.BPriv";s:8:"\0*\0BProt";s:7:"B.BProt";s:4:"BPub";s:6:"B.BPub";}"
Unserialized:
object(B)#%d (6) {
["BPriv":"B":private]=>
string(7) "B.BPriv"
["BProt":protected]=>
string(7) "B.BProt"
["BPub"]=>
string(6) "B.BPub"
["APriv":"A":private]=>
string(7) "A.APriv"
["AProt":protected]=>
string(7) "A.AProt"
["APub"]=>
string(6) "A.APub"
["BPriv":"B":private]=>
string(7) "B.BPriv"
["BProt":protected]=>
string(7) "B.BProt"
["BPub"]=>
string(6) "B.BPub"
}
Sanity check: bool(true)
@ -135,51 +135,51 @@ Sanity check: bool(true)
Before serialization:
object(C)#%d (10) {
["APriv":"C":private]=>
string(7) "C.APriv"
["APriv":"A":private]=>
string(7) "A.APriv"
["AProt":protected]=>
string(7) "C.AProt"
["APub"]=>
string(6) "C.APub"
["CPriv":"C":private]=>
string(7) "C.CPriv"
["CProt":protected]=>
string(7) "C.BProt"
["CPub"]=>
string(6) "C.CPub"
["BPriv":"B":private]=>
string(7) "B.BPriv"
["BProt":protected]=>
string(7) "B.BProt"
["BPub"]=>
string(6) "B.BPub"
["APriv":"A":private]=>
string(7) "A.APriv"
["APriv":"C":private]=>
string(7) "C.APriv"
["CPriv":"C":private]=>
string(7) "C.CPriv"
["CProt":protected]=>
string(7) "C.BProt"
["CPub"]=>
string(6) "C.CPub"
}
Serialized form:
string(302) "O:1:"C":10:{s:8:"\0C\0APriv";s:7:"C.APriv";s:8:"\0*\0AProt";s:7:"C.AProt";s:4:"APub";s:6:"C.APub";s:8:"\0C\0CPriv";s:7:"C.CPriv";s:8:"\0*\0CProt";s:7:"C.BProt";s:4:"CPub";s:6:"C.CPub";s:8:"\0B\0BPriv";s:7:"B.BPriv";s:8:"\0*\0BProt";s:7:"B.BProt";s:4:"BPub";s:6:"B.BPub";s:8:"\0A\0APriv";s:7:"A.APriv";}"
string(302) "O:1:"C":10:{s:8:"\0A\0APriv";s:7:"A.APriv";s:8:"\0*\0AProt";s:7:"C.AProt";s:4:"APub";s:6:"C.APub";s:8:"\0B\0BPriv";s:7:"B.BPriv";s:8:"\0*\0BProt";s:7:"B.BProt";s:4:"BPub";s:6:"B.BPub";s:8:"\0C\0APriv";s:7:"C.APriv";s:8:"\0C\0CPriv";s:7:"C.CPriv";s:8:"\0*\0CProt";s:7:"C.BProt";s:4:"CPub";s:6:"C.CPub";}"
Unserialized:
object(C)#%d (10) {
["APriv":"C":private]=>
string(7) "C.APriv"
["APriv":"A":private]=>
string(7) "A.APriv"
["AProt":protected]=>
string(7) "C.AProt"
["APub"]=>
string(6) "C.APub"
["CPriv":"C":private]=>
string(7) "C.CPriv"
["CProt":protected]=>
string(7) "C.BProt"
["CPub"]=>
string(6) "C.CPub"
["BPriv":"B":private]=>
string(7) "B.BPriv"
["BProt":protected]=>
string(7) "B.BProt"
["BPub"]=>
string(6) "B.BPub"
["APriv":"A":private]=>
string(7) "A.APriv"
["APriv":"C":private]=>
string(7) "C.APriv"
["CPriv":"C":private]=>
string(7) "C.CPriv"
["CProt":protected]=>
string(7) "C.BProt"
["CPub"]=>
string(6) "C.CPub"
}
Sanity check: bool(true)
Done

View File

@ -28,15 +28,6 @@ array(1) {
int(1)
}
object(myZip)#1 (%d) {
["test":"myZip":private]=>
int(0)
["testp"]=>
string(6) "foobar"
["testarray":"myZip":private]=>
array(1) {
[0]=>
int(1)
}
["lastId"]=>
int(-1)
["status"]=>
@ -49,4 +40,13 @@ object(myZip)#1 (%d) {
string(0) ""
["comment"]=>
string(0) ""
["test":"myZip":private]=>
int(0)
["testp"]=>
string(6) "foobar"
["testarray":"myZip":private]=>
array(1) {
[0]=>
int(1)
}
}

View File

@ -14,15 +14,6 @@ array(1) {
int(1)
}
object(myZip)#1 (%d) {
["test":"myZip":private]=>
int(0)
["testp"]=>
string(6) "foobar"
["testarray":"myZip":private]=>
array(1) {
[0]=>
int(1)
}
["lastId"]=>
int(-1)
["status"]=>
@ -35,4 +26,13 @@ object(myZip)#1 (%d) {
string(0) ""
["comment"]=>
string(0) ""
["test":"myZip":private]=>
int(0)
["testp"]=>
string(6) "foobar"
["testarray":"myZip":private]=>
array(1) {
[0]=>
int(1)
}
}

View File

@ -37,20 +37,20 @@ Object
test Object
(
[p1] => test:1
[p2] => base:2
[p3] => test:3
[p4] => A
[p5] => test:5
[p2] => base:2
[p6:base:private] => base:6
)
Clown
test Object
(
[p1] => test:1
[p2] => base:2
[p3] => test:3
[p4] => A
[p5] => clone:5
[p2] => base:2
[p6:base:private] => base:6
)
Done

View File

@ -40,13 +40,6 @@ echo "Done\n";
--EXPECT--
Original
object(test)#1 (2) {
["b"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(4)
}
["a"]=>
array(2) {
[0]=>
@ -54,16 +47,16 @@ object(test)#1 (2) {
[1]=>
int(2)
}
["b"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(4)
}
}
Clone
object(test)#2 (2) {
["b"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(4)
}
["a"]=>
array(2) {
[0]=>
@ -71,12 +64,19 @@ object(test)#2 (2) {
[1]=>
int(2)
}
["b"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(4)
}
}
Modify
object(test)#2 (2) {
["b"]=>
int(6)
["a"]=>
int(5)
["b"]=>
int(6)
}
Done

View File

@ -80,6 +80,11 @@ object(B)#%d (1) {
}
}
object(C)#%d (3) {
["a_b"]=>
array(1) {
["key"]=>
string(5) "value"
}
["a_c_parent"]=>
array(1) {
["key"]=>
@ -90,9 +95,4 @@ object(C)#%d (3) {
["key"]=>
string(5) "value"
}
["a_b"]=>
array(1) {
["key"]=>
string(5) "value"
}
}

View File

@ -67,31 +67,31 @@ base Object
Testing class derived
derived Object
(
[other] => other
[name] => init
[other] => other
)
base::__construct
derived Object
(
[other] => other
[name] => base
[other] => other
)
derived::__construct
derived Object
(
[other] => other
[name] => derived
[other] => other
)
base::__destruct
derived Object
(
[other] => other
[name] => derived
[other] => other
)
derived::__destruct
derived Object
(
[other] => other
[name] => derived
[other] => other
)
Done

View File

@ -17,8 +17,8 @@ var_dump(new C);
?>
--EXPECTF--
object(C)#%d (2) {
["c":"B":private]=>
NULL
["c":"A":private]=>
NULL
["c":"B":private]=>
NULL
}

View File

@ -57,45 +57,45 @@ base::__construct(begin)
base::test
derived Object
(
[member] => derived::member (default)
[member:base:private] => base::member
[member] => derived::member (default)
)
derived::test
derived Object
(
[member] => derived::member (default)
[member:base:private] => base::member
[member] => derived::member (default)
)
base::__construct(end)
base::test
derived Object
(
[member] => derived::member (default)
[member:base:private] => base::member
[member] => derived::member (default)
)
base::test
derived Object
(
[member] => derived::member (default)
[member:base:private] => base::member
[member] => derived::member (default)
)
derived::test
derived Object
(
[member] => derived::member (default)
[member:base:private] => base::member
[member] => derived::member (default)
)
derived::__construct(end)
base::test
derived Object
(
[member] => derived::member
[member:base:private] => base::member
[member] => derived::member
)
derived::test
derived Object
(
[member] => derived::member
[member:base:private] => base::member
[member] => derived::member
)
Done

View File

@ -191,17 +191,13 @@ object(C)#%d (5) {
--> Using instance of D:
in D::doForEachOnThis
string(10) "Original f"
string(10) "Original g"
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
string(10) "Original f"
string(10) "Original g"
object(D)#%d (7) {
["f":"D":private]=>
string(9) "changed.f"
["g":protected]=>
string(9) "changed.g"
["a"]=>
string(9) "changed.a"
["b"]=>
@ -212,6 +208,10 @@ object(D)#%d (7) {
string(9) "changed.d"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(9) "changed.f"
["g":protected]=>
string(9) "changed.g"
}
--> Using instance of E:
@ -220,8 +220,8 @@ string(12) "Overridden a"
string(12) "Overridden b"
string(12) "Overridden c"
string(12) "Overridden d"
string(12) "Overridden e"
string(10) "Original g"
string(12) "Overridden e"
object(E)#%d (8) {
["a"]=>
string(9) "changed.a"
@ -231,14 +231,14 @@ object(E)#%d (8) {
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"E":private]=>
string(9) "changed.e"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
["e":"C":private]=>
string(10) "Original e"
["e":"E":private]=>
string(9) "changed.e"
}
@ -266,17 +266,13 @@ object(C)#%d (5) {
--> Using instance of D:
in C::doForEachC
string(10) "Original g"
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
string(10) "Original e"
string(10) "Original g"
object(D)#%d (7) {
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
["a"]=>
string(9) "changed.a"
["b"]=>
@ -287,6 +283,10 @@ object(D)#%d (7) {
string(9) "changed.d"
["e":"C":private]=>
string(9) "changed.e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
}
--> Using instance of E:
@ -295,8 +295,8 @@ string(12) "Overridden a"
string(12) "Overridden b"
string(12) "Overridden c"
string(12) "Overridden d"
string(10) "Original g"
string(10) "Original e"
string(10) "Original g"
object(E)#%d (8) {
["a"]=>
string(9) "changed.a"
@ -306,14 +306,14 @@ object(E)#%d (8) {
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"E":private]=>
string(12) "Overridden e"
["e":"C":private]=>
string(9) "changed.e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
["e":"C":private]=>
string(9) "changed.e"
["e":"E":private]=>
string(12) "Overridden e"
}
@ -375,17 +375,13 @@ object(C)#%d (5) {
--> Using instance of D:
in C::doForEach
string(10) "Original g"
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
string(10) "Original e"
string(10) "Original g"
object(D)#%d (7) {
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
["a"]=>
string(9) "changed.a"
["b"]=>
@ -396,41 +392,19 @@ object(D)#%d (7) {
string(9) "changed.d"
["e":"C":private]=>
string(9) "changed.e"
}
in D::doForEach
string(10) "Original f"
string(10) "Original g"
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
object(D)#%d (7) {
["f":"D":private]=>
string(9) "changed.f"
["g":protected]=>
string(9) "changed.g"
["a"]=>
string(9) "changed.a"
["b"]=>
string(9) "changed.b"
["c"]=>
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"C":private]=>
string(10) "Original e"
}
in E::doForEach
string(10) "Original g"
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
object(D)#%d (7) {
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
}
in D::doForEach
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
string(10) "Original f"
string(10) "Original g"
object(D)#%d (7) {
["a"]=>
string(9) "changed.a"
["b"]=>
@ -441,6 +415,32 @@ object(D)#%d (7) {
string(9) "changed.d"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(9) "changed.f"
["g":protected]=>
string(9) "changed.g"
}
in E::doForEach
string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
string(10) "Original d"
string(10) "Original g"
object(D)#%d (7) {
["a"]=>
string(9) "changed.a"
["b"]=>
string(9) "changed.b"
["c"]=>
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
}
--> Using instance of E:
@ -449,8 +449,8 @@ string(12) "Overridden a"
string(12) "Overridden b"
string(12) "Overridden c"
string(12) "Overridden d"
string(10) "Original g"
string(10) "Original e"
string(10) "Original g"
object(E)#%d (8) {
["a"]=>
string(9) "changed.a"
@ -460,14 +460,14 @@ object(E)#%d (8) {
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"E":private]=>
string(12) "Overridden e"
["e":"C":private]=>
string(9) "changed.e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
["e":"C":private]=>
string(9) "changed.e"
["e":"E":private]=>
string(12) "Overridden e"
}
in D::doForEach
string(12) "Overridden a"
@ -485,22 +485,22 @@ object(E)#%d (8) {
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"E":private]=>
string(12) "Overridden e"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(9) "changed.f"
["g":protected]=>
string(9) "changed.g"
["e":"C":private]=>
string(10) "Original e"
["e":"E":private]=>
string(12) "Overridden e"
}
in E::doForEach
string(12) "Overridden a"
string(12) "Overridden b"
string(12) "Overridden c"
string(12) "Overridden d"
string(12) "Overridden e"
string(10) "Original g"
string(12) "Overridden e"
object(E)#%d (8) {
["a"]=>
string(9) "changed.a"
@ -510,14 +510,14 @@ object(E)#%d (8) {
string(9) "changed.c"
["d":protected]=>
string(9) "changed.d"
["e":"E":private]=>
string(9) "changed.e"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(9) "changed.g"
["e":"C":private]=>
string(10) "Original e"
["e":"E":private]=>
string(9) "changed.e"
}
@ -545,10 +545,6 @@ string(10) "Original a"
string(10) "Original b"
string(10) "Original c"
object(D)#%d (7) {
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(10) "Original g"
["a"]=>
string(9) "changed.a"
["b"]=>
@ -559,6 +555,10 @@ object(D)#%d (7) {
string(10) "Original d"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(10) "Original g"
}
--> Using instance of E:
@ -574,12 +574,12 @@ object(E)#%d (8) {
&string(9) "changed.c"
["d":protected]=>
string(12) "Overridden d"
["e":"E":private]=>
string(12) "Overridden e"
["e":"C":private]=>
string(10) "Original e"
["f":"D":private]=>
string(10) "Original f"
["g":protected]=>
string(10) "Original g"
["e":"C":private]=>
string(10) "Original e"
["e":"E":private]=>
string(12) "Overridden e"
}