Hacker News new | past | comments | ask | show | jobs | submit login

That would probably be union types[0] (or plain old dynamic typing) with checks like `is_null($val)` and `$val instanceof Type`.

Offline typecheckers (not included with PHP) can analyze the control flow to prove that any invalid types have been ruled out when an operation happens. It's not nearly as principled as proper sum types, but it works alright in practice.

PHP's upcoming enums are simple values, more like C's enums than Rust's enums.

[0]: https://www.php.net/manual/en/language.types.declarations.ph...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: