3v4l.org

run code in 300+ PHP versions simultaneously
<?php class T { } class X { public function __construct(T $t) { $this->t = $t; } } class Builder { /** * @var T|null */ public $t; public function createX(): X { $this->validate(); // PHPStan complains that at this line, $this->t could be null, except we've already checked it isn't... // Parameter #1 $t of class X constructor expects T, T|null given. return new X($this->t); } private function validate() { if (is_null($this->t)) { throw new \Exception; } } } $builder = new Builder; $builder->t = new T; $builder->createX();
Output for git.master_jit, git.master, rfc.property-hooks
Deprecated: Creation of dynamic property X::$t is deprecated in /in/WkL0Y on line 7

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