This is very half-baked, but I'm capturing an idea I wrote in an empty buffer.
This provides a similar behavior to Rust's std::option::Option
enum which encapsulates a value either existing as it should as "Some" value, or being empty or "None".
There's also a convenience for pattern matching, though more would need to go into the typing with PHPStan docstrings to make it more dynamic. As it is now though, it's possible to act on a Some
or None
match with a closure for the items.