Re: [RFC][Draft] Sealed Classes
| From: | David Gebler | Date: | Tue, 27 Apr 2021 22:48:04 +0000 |
| Subject: | Re: [RFC][Draft] Sealed Classes | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114218@lists.php.net to get a copy of this message | ||
On Tue, Apr 27, 2021 at 11:23 PM Larry Garfield <larry@garfieldtech.com>
wrote:
The two options to prevent such errors are:
>
> 1. Sealed classes.
> 2. Extend Enums into ADTs.
>
Unless I've misunderstood your example, there is a third option which quite
possibly prevents the error in a nicer, easier to reason about, more
flexible pattern.
class Perhaps extends Maybe implements OperatesOnTheValueInterface { ... }