3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); final readonly class Version { private string $version; private function __construct( string $version ){ // TODO: ensure is valid $this->version = $version; } public static function fromString(string $string): self { return new self($string); } } final readonly class Example { private ?Version $modifiedVersionForCloning = null; public function __construct( public Version $version ) {} public function __clone() { $this->version = $this->modifiedVersionForCloning; $this->modifiedVersionForCloning = null; } public function lol(string $version): self { $this->modifiedVersionForCloning = Version::fromString($version); $clone = clone $this; return $clone; } } $example = new Example(Version::fromString('8.2')); var_dump($example->lol('8.3'));
Output for rfc.property-hooks, git.master, git.master_jit
Fatal error: Readonly property Example::$modifiedVersionForCloning cannot have default value in /in/DJhth on line 24
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:
49.95 ms | 699 KiB | 3 Q