3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @template T of int|numeric-string */ class Foo { /** @param T $bar */ public function __construct(public $bar) {} } function bar(Foo $foo): void { $foo->bar = 123; } /** @var Foo<numeric-string> $foo */ $foo = new Foo("123"); bar($foo); assert(is_string($foo->bar));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught AssertionError: assert(is_string($foo->bar)) in /in/TD3a6:21 Stack trace: #0 /in/TD3a6(21): assert(false, 'assert(is_strin...') #1 {main} thrown in /in/TD3a6 on line 21
Process exited with code 255.

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:
25.28 ms | 405 KiB | 5 Q