3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Permission implements \Serializable { protected $id = 3; public function serialize() { return serialize(array($this->id)); } public function unserialize($serialized) { list($this->id) = unserialize($serialized); } } class UserPermission implements \Serializable { public $permission; public $webshop; public function serialize() { return serialize(array($this->webshop, $this->permission)); } public function unserialize($serialized) { list($this->webshop, $this->permission) = unserialize($serialized); } } class Webshop implements \Serializable { protected $id = 13; public function serialize() { return serialize(array($this->id)); } public function unserialize($serialized) { list($this->id) = unserialize($serialized); } } class AbstractToken implements \Serializable { public $roles; public function serialize() { return serialize(array($this->roles)); } public function unserialize($serialized) { list($this->roles) = unserialize($serialized); } } class UsernamePasswordToken extends AbstractToken { private $credentials = null; private $providerKey = null; public function serialize() { return serialize(array($this->credentials, $this->providerKey, parent::serialize())); } public function unserialize($str) { list($this->credentials, $this->providerKey, $parentStr) = unserialize($str); parent::unserialize($parentStr); } } $token = new UsernamePasswordToken(); $webshop = new Webshop; $permission = new Permission; $roles = array(); for ($i = 0; $i < 2; $i++) { $roles[$i] = new UserPermission(); $roles[$i]->webshop = $webshop; $roles[$i]->permission = $permission; } $token->roles = $roles; var_dump(unserialize(serialize($token)));

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Arrow functions
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } [1]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }
Output for Object typehint
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } [1]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }
Output for Array change keys
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> array(1) { [0]=> *RECURSION* } [1]=> *RECURSION* } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }
Output for Lexical anon
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> array(1) { [0]=> *RECURSION* } [1]=> *RECURSION* } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }
Output for Typed properties
object(UsernamePasswordToken)#6 (3) { ["credentials":"UsernamePasswordToken":private]=> NULL ["providerKey":"UsernamePasswordToken":private]=> NULL ["roles"]=> array(2) { [0]=> object(UserPermission)#7 (2) { ["permission"]=> object(Permission)#9 (1) { ["id":protected]=> int(3) } ["webshop"]=> object(Webshop)#8 (1) { ["id":protected]=> int(13) } } [1]=> object(UserPermission)#10 (2) { ["permission"]=> array(2) { [0]=> array(1) { [0]=> *RECURSION* } [1]=> *RECURSION* } ["webshop"]=> array(1) { [0]=> *RECURSION* } } } }

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page