Hello,

I would like to get RFC Karma for my wiki account. My username is: jkroon.
The proposed RFC will introduce Enums with Associated Values for cases and is 
inspired by Rust and Swift.

For example it would allow for the following:

```
<?php

enum ApiResult {
    case Success(string $data, int $statusCode);
    case Failure(Throwable $error, ?int $statusCode);
}

function handle(ApiResult $r): string {
    return match ($r) {
        ApiResult::Success => 'OK ' . $r->statusCode . PHP_EOL,
        ApiResult::Failure => 'NO ' . ($r->statusCode ?? 'unknown') . PHP_EOL,
    };
}

echo handle(ApiResult::Success('All good', 200));
echo handle(ApiResult::Failure(new Exception('Bad request'), 400));
echo handle(ApiResult::Failure(new Exception('Server error'), null));
```

Regards,
Jordi

Reply via email to