3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ValidationError { public function __construct( public string $message ) {} } function validate(string $errorsOnPoupanka): bool|ValidationError { if ( $errorsOnPoupanka === 'poupanka') return new ValidationError("Poupanka error"); return true; } var_dump(match(validate("poupanka")) { ValidationError::class => $validationResult->message, true => "Nice", });
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Uncaught UnhandledMatchError: Unhandled match case of type ValidationError in /in/sB1kM:19 Stack trace: #0 {main} thrown in /in/sB1kM on line 19
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Fatal error: Uncaught UnhandledMatchError: Unhandled match value of type ValidationError in /in/sB1kM:19 Stack trace: #0 {main} thrown in /in/sB1kM on line 19
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/sB1kM on line 6
Process exited with code 255.

preferences:
123.43 ms | 409 KiB | 5 Q