-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow serialize of inherited classes.
- Loading branch information
Showing
10 changed files
with
226 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@ok k2_skip | ||
<?php | ||
require_once 'kphp_tester_include.php'; | ||
|
||
/** @kphp-serializable */ | ||
class Base { | ||
/** | ||
* @kphp-serialized-field 1 | ||
* @var int | ||
*/ | ||
public $b = 10; | ||
} | ||
|
||
/** @kphp-serializable */ | ||
class A extends Base { | ||
/** | ||
* @kphp-serialized-field 2 | ||
* @var int | ||
*/ | ||
public $x = 10; | ||
|
||
/** | ||
* @kphp-serialized-field 3 | ||
* @var int | ||
*/ | ||
public $y = 10; | ||
} | ||
|
||
$a = new A(); | ||
instance_serialize($a); |
34 changes: 34 additions & 0 deletions
34
tests/phpt/msgpack_serialize/027_serialize_intermediate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@ok k2_skip | ||
<?php | ||
require_once 'kphp_tester_include.php'; | ||
|
||
class Base { | ||
public function foo() { var_dump("OK"); } | ||
} | ||
|
||
/** @kphp-serializable */ | ||
class A extends Base { | ||
/** | ||
* @kphp-serialized-field 1 | ||
* @var int | ||
*/ | ||
public $x = 10; | ||
} | ||
|
||
class B extends A { | ||
} | ||
|
||
/** @kphp-serializable */ | ||
class C extends B { | ||
/** | ||
* @kphp-serialized-field 2 | ||
* @var int | ||
*/ | ||
public $y = 12; | ||
} | ||
|
||
$c = new C(); | ||
$str = instance_serialize($c); | ||
$c->foo(); | ||
$c_new = instance_deserialize($str, C::class); | ||
$c_new->foo(); |
50 changes: 50 additions & 0 deletions
50
tests/phpt/msgpack_serialize/028_deserialize_inherited.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@ok k2_skip | ||
<?php | ||
require_once 'kphp_tester_include.php'; | ||
|
||
class Base { | ||
public function foo() { var_dump("OK"); } | ||
} | ||
|
||
/** @kphp-serializable */ | ||
class A extends Base { | ||
/** | ||
* @kphp-serialized-field 1 | ||
* @var int | ||
*/ | ||
public $x = 10; | ||
} | ||
|
||
/** @kphp-serializable */ | ||
class B extends A { | ||
/** | ||
* @kphp-serialized-field 2 | ||
* @var int | ||
*/ | ||
public $y = 10; | ||
} | ||
|
||
/** @kphp-serializable */ | ||
class C extends B { | ||
/** | ||
* @kphp-serialized-field 3 | ||
* @var int | ||
*/ | ||
public $z = 12; | ||
} | ||
|
||
$c0 = new C(); | ||
$str = instance_serialize($c0); | ||
$c0->foo(); | ||
|
||
$c = instance_deserialize($str, C::class); | ||
$b = instance_deserialize($str, B::class); | ||
$a = instance_deserialize($str, A::class); | ||
|
||
var_dump(instance_to_array($a)); | ||
var_dump(instance_to_array($b)); | ||
var_dump(instance_to_array($c)); | ||
|
||
$a->foo(); | ||
$b->foo(); | ||
$c->foo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/phpt/msgpack_serialize/113_duplicated_inherited_tags.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@kphp_should_fail k2_skip | ||
/kphp-serialized-field: field with number 1 found in both classes A and B/ | ||
<?php | ||
|
||
require_once 'kphp_tester_include.php'; | ||
|
||
/** @kphp-serializable */ | ||
class A { | ||
/** | ||
* @kphp-serialized-field 1 | ||
* @var int | ||
*/ | ||
public $x = 10; | ||
|
||
} | ||
|
||
/** @kphp-serializable */ | ||
class B extends A { | ||
/** | ||
* @kphp-serialized-field 1 | ||
* @var int | ||
*/ | ||
public $y = 10; | ||
} | ||
|
||
$b = new B(); | ||
instance_serialize($b); |