3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private int $foo; function __construct(int $foo){ $this->foo = $foo; } function getFoo(): int{ return $this->foo; } } class Baz extends Foo { function __construct(){ // there, you broke encapsulation as you didn't call parent::__construct() // having fields typechecked after construction would actually enforce the call of base constructors } } (new Baz())->getFoo(); // rekt
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Typed property Foo::$foo must not be accessed before initialization in /in/CqTIA:11 Stack trace: #0 /in/CqTIA(23): Foo->getFoo() #1 {main} thrown in /in/CqTIA on line 11
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:
160.15 ms | 405 KiB | 5 Q