Re: [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed
| From: | Guilliam Xavier | Date: | Thu, 16 Apr 2020 14:22:15 +0000 |
| Subject: | Re: [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-109686@lists.php.net to get a copy of this message | ||
On Sun, Apr 5, 2020 at 4:02 PM Gabriel Caruso <carusogabriel34@gmail.com> wrote:
>
> Hello, internals.
>
> Hereby you can find the RFC Document that I want to discuss as suggested
> via https://externals.io/message/109416 and
> https://externals.io/message/107990:
>
> https://wiki.php.net/rfc/magic-methods-signature
>
> Best regards,
>
> -- Gabriel Caruso
Hello,
Thank you, this seems a sensible thing to add.
Just an interrogation: the following magic methods (from the
documentation) aren't mentioned at all in the RFC:
-
__sleep(): array
- __wakeup(): void
- __unserialize(array $data): void
- (__invoke is basically untyped)
- __set_state(array $properties): object
- __debugInfo(): array
Is there a reason for leaving them out?
Related, the RFC mentions that __serialize and __toString already
have a *runtime* check that they respectively return an array and a
string (when called), but why not check their signature (if typed)
at *compile time* too (i.e. make https://3v4l.org/ZPrVi an
error)?
Regards,
--
Guilliam Xavier