3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface EntityInterface { } class EntityDecorator implements EntityInterface { public $subject; public function __construct(EntityInterface $subject) { $this->subject = $subject instanceof static ? $subject->getEntity() : $subject; } public function getEntity() { return $this->subject; } } class Entity implements EntityInterface {} class DecoratorA extends EntityDecorator {} class DecoratorB extends EntityDecorator {} $entity = new Entity(); var_dump($entity); $a = new DecoratorA($entity); var_dump($a); $b = new DecoratorB($a); var_dump($b); $b2 = new DecoratorB($b); var_dump($b2); $a2 = new DecoratorA($b2); var_dump($a2);
Output for git.master, git.master_jit, rfc.property-hooks
object(Entity)#1 (0) { } object(DecoratorA)#2 (1) { ["subject"]=> object(Entity)#1 (0) { } } object(DecoratorB)#3 (1) { ["subject"]=> object(DecoratorA)#2 (1) { ["subject"]=> object(Entity)#1 (0) { } } } object(DecoratorB)#4 (1) { ["subject"]=> object(DecoratorA)#2 (1) { ["subject"]=> object(Entity)#1 (0) { } } } object(DecoratorA)#5 (1) { ["subject"]=> object(DecoratorB)#4 (1) { ["subject"]=> object(DecoratorA)#2 (1) { ["subject"]=> object(Entity)#1 (0) { } } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

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


preferences:
53.14 ms | 402 KiB | 8 Q