# RFC Karma request: Enums with Associated Values for cases

- Thread: https://externals.io/message/130006
- Original archive: https://news-web.php.net/php.internals/130006
- Started by Jordi Kroon on 2026-02-04T12:16:36+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #130006 — Jordi Kroon — 2026-02-04T12:16:36+00:00

URL: https://externals.io/message/130006#130006

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
