3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); abstract class User { public const STATUS_ACTIVE = 'active'; public const STATUS_INACTIVE = 'inactive'; public function __construct(public string $email, public string $status = self::STATUS_ACTIVE) { } public function setStatus(string $status): void { assert( in_array($status, [self::STATUS_ACTIVE, self::STATUS_INACTIVE]), sprintf('Le status %s n\'est pas valide. Les status possibles sont : %s', $status, [self::STATUS_ACTIVE, self::STATUS_INACTIVE]) ); $this->status = $status; } public function getStatus(): string { return $this->status; } abstract public function getUsername(): string; } abstract class Player extends User { // Ajout d'un tableau de roles pour affiner les droits des administrateurs :) public function __construct(string $email, public string $username, string $status = self::STATUS_ACTIVE) { parent::__construct($email, $status); } // ... } class QueuingPlayer extends Player { public function getUsername(): string { return $this->username; } } $Qp = new QueuingPlayer('roland@gras.ros', 'Roland'); var_dump($Qp);
Output for git.master_jit, git.master, rfc.property-hooks
object(QueuingPlayer)#1 (3) { ["email"]=> string(15) "roland@gras.ros" ["status"]=> string(6) "active" ["username"]=> string(6) "Roland" }

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