3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Hook { public function __construct( public string $hook, public string $method = '', public ?string $module = NULL, ) {} } class Alter extends Hook { public function __construct( public string $hook, public string $method = '', public ?string $module = NULL, ) { parent::__construct($hook . '_alter'); } } class FormAlter extends Alter { public function __construct( public string $hook = '', public string $method = '', public ?string $module = NULL, ) { parent::__construct($hook ? 'form_' . $hook : 'form'); } } var_dump(new Alter('foo')); var_dump(new FormAlter()); var_dump(new FormAlter('foo'));

preferences:
33.4 ms | 404 KiB | 5 Q