3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface FormStateInterface {} class FormState implements FormStateInterface {} class Config {} class ConfigFormBase { public function submitForm(array &$form, FormStateInterface $form_state) { var_dump(in_array(ValidatableConfigFormTrait::class, class_uses($this))); } } trait ValidatableConfigFormTrait { abstract protected static function mapFormValuesToConfig(FormStateInterface $form_state, Config $config): void; } class MyForm extends ConfigFormBase { use ValidatableConfigFormTrait; protected static function mapFormValuesToConfig(FormStateInterface $form_state, Config $config): void { // without this, PHP will complain! 👍 } } class SubMyForm extends MyForm {} $form = []; (new MyForm())->submitForm($form, new FormState()); (new SubMyForm())->submitForm($form, new FormState());
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
bool(true) bool(false)

preferences:
74.85 ms | 406 KiB | 5 Q