3v4l.org

run code in 300+ PHP versions simultaneously
<?php use Webmozart\Assert\Assert; final class Button { public string $text = ''; public string $type = 'button' { set { Assert::oneOf($value, ['button', 'reset', 'submit']); $this->type = $value; } } } $var = new Button(); $var->text = 'hey'; $var->type = 'bazongas'; print_r($var);
Output for 8.4.1 - 8.4.3
Fatal error: Uncaught Error: Class "Webmozart\Assert\Assert" not found in /in/ALRcJt:11 Stack trace: #0 /in/ALRcJt(19): Button->$type::set('bazongas') #1 {main} thrown in /in/ALRcJt on line 11
Process exited with code 255.
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.16
Parse error: syntax error, unexpected token ";" in /in/ALRcJt on line 11
Process exited with code 255.

preferences:
149.65 ms | 954 KiB | 7 Q