3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tap($target) { return new HigherOrderTapProxy($target); } class HigherOrderTapProxy { public $target; public function __construct($target) { $this->target = $target; } public function __call($method, $parameters) { $this->target->{$method}(...$parameters); return $this->target; } } class Number { public $value; public function __construct($value) { $this->value = $value; } public function add($value) { $this->value += $value; } public function get() { return $this->value; } } tap($number = new Number(5)) ->add(10) ->add(20); var_dump($number);

preferences:
23.88 ms | 404 KiB | 5 Q