3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Promise { public $value; public function __construct($value) { $this->value = $value; } public function when(callable $callable) { $callable($this->value); } } $promise = new Promise(new StdClass); var_dump($promise); $promise->when(function(&$when) { $when = 42; }); var_dump($promise);
Output for 5.5.0 - 7.3.0beta1
object(Promise)#1 (1) { ["value"]=> object(stdClass)#2 (0) { } } object(Promise)#1 (1) { ["value"]=> int(42) }