Created
April 1, 2016 09:08
-
-
Save alexandr-parkhomenko/21552f83306fc7617d71b71db5424200 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
class Identity | |
{ | |
private $role; | |
public function __construct($role) | |
{ | |
$this->role = $role; | |
} | |
} | |
class Entry implements \Serializable | |
{ | |
private $identity; | |
public function __construct(Identity $identity) | |
{ | |
$this->identity = $identity; | |
} | |
public function serialize() | |
{ | |
return serialize(array($this->identity)); | |
} | |
public function unserialize($serialized) | |
{ | |
list($this->identity) = unserialize($serialized); | |
} | |
} | |
$identity = new Identity('test'); | |
$identityRef = &$identity; | |
$entry1 = new Entry($identity); | |
$entry2 = new Entry($identityRef); | |
$serialized = serialize([$entry1, $entry2]); | |
print_r(unserialize($serialized)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment