A major behavior i wanted to discuss is how should sealed interfaces work, and specially around
Throwable which is currently sealed to only Error and
Exception, but allows other interfaces to extend it, and other classes to implement it
as long as they extend Error or Exception ( or another class that does so
).
As per the current proposal, if Throwable is to be declared sealed,
permitting only Error and Exception, it won't be possible to extend
it, resulting in a major BC-break, considering that too many libraries extend this interface in
their own ExceptionInterface.
To work around this, there's two solution:
1. don't declare Throwable sealed and keep it as a special case.
2. interfaces declared sealed, can be extended by other interfaces, however, classes that implement
either the sealed interface directly, or via another interface, have to extend one of the classes
the sealed interface permits.
The second solution will allow declaring Throwable sealed, and would bring complete
consistency between internally sealed symbols, and user land, without any BC breaks, and IMHO, it
doesn't hurt as at the end, no one will be able to implement Throwable without
extending the permitted classes..
Note: with the second solution, if an interface is sealed and permits only 2 classes which are
final, and you extend that interface into another, there's no way you can actually implement
your new interface, and i will be as if you just declared a final interface.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, April 24, 2021 11:55 AM, Saif Eddin Gmati <azjezz@protonmail.com> wrote:
> Hello Internals,
>
> I'm sending this email to open discussion about sealed classes, interfaces, and traits
> feature for PHP 8.1.
>
> I have create a Draft RFC here: https://wiki.php.net/rfc/sealed_classes
>
> A major concern for few people have been the syntax, in which it introduces 2 new keywords into
> the languages, therefor, i have added a section about alternative syntax which could be used to
> avoid this problem.
>
> Regards,
>
> Saif.
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc