3v4l.org

run code in 200+ php & hhvm versions
<?php declare(strict_types = 1); class A { function f(): string { return (string) (new A()); } function __toString() { return "5"; } } echo (new A())->f(); echo "\n\r"; echo ((new A())->f()) + "2";
Output for 7.1.25 - 7.3.3
5 7