3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Schema { private static array $tables = [ 'user' => [ 'id' => 'int', 'name' => 'string', ] ]; public static function getTableColumnByName(string $tableName, string $columnName): TableColumn { if (false === array_key_exists($tableName, static::$tables)) { throw new Exception(static::class . ' table "' . $tableName . '" not found.'); } if (false === array_key_exists($columnName, static::$tables[$tableName])) { throw new Exception('Table "' . $tableName . '" column "' . $columnName . '" not found.'); } return new TableColumn($columnName, static::$tables[$tableName][$columnName]); } } class UserTableGateway { public function update(int $id, TableColumn $column, mixed $value): void { echo 'Zaebis! Sohranil: "' . $value . '"'; } } class TableColumn { public function __construct( public readonly string $name, public readonly string $type, ) {} } $gateway = new UsertableGateway; $gateway->update(33, Schema::getTableColumnByName('user', 'name'), 'Vasya'); $gateway->update(33, Schema::getTableColumnByName('user', 'familiya'), 'Vasya');
Output for git.master, git.master_jit, rfc.property-hooks
Zaebis! Sohranil: "Vasya" Fatal error: Uncaught Exception: Table "user" column "familiya" not found. in /in/fugVD:17 Stack trace: #0 /in/fugVD(39): Schema::getTableColumnByName('user', 'familiya') #1 {main} thrown in /in/fugVD on line 17
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:
37.91 ms | 405 KiB | 5 Q