Skip to content

Instantly share code, notes, and snippets.

@alexandr-parkhomenko
Created April 1, 2016 09:08
Show Gist options
  • Save alexandr-parkhomenko/21552f83306fc7617d71b71db5424200 to your computer and use it in GitHub Desktop.
Save alexandr-parkhomenko/21552f83306fc7617d71b71db5424200 to your computer and use it in GitHub Desktop.
<?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