Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109690 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42187 invoked from network); 16 Apr 2020 16:54:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Apr 2020 16:54:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 02FE01804E4 for ; Thu, 16 Apr 2020 08:24:25 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 16 Apr 2020 08:24:24 -0700 (PDT) Received: by mail-io1-f47.google.com with SMTP id i3so21385440ioo.13 for ; Thu, 16 Apr 2020 08:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mxpqEuyw4hz1MIOmCFCUGDiDhXbHwrRBQ37/cpaAH0I=; b=NWLSWvQTt6LUF6LK1R5zEF5eyxz+zoMk0tP0uwk8Y8ClA11+PFBQ47RAo+J6RG4Cs9 uiw/yipdnvLLJWTvzXnOk19Cyg+ZVkTlWUh8hkkJEL9yezygQc01H4dEmvbW7VnsVj0b dgq1zQsYmQrKDeOXBIrRTvsSMQleuJ0ipKNwKKH1sZrKQq/gZ3gae9AKcMxj9c4CVzMV cZD8zX+jNjaj6WjJT6UpMRwenvdrVkyIa3AtOFlSCPe78bYYEU5YrVbYNbNC7eVP2ln2 Y7GMMQwCEpx89lqFUhflwhRKSI2rRUCexYy+lehhhlKF0GE1141tDixTV8HMGeCh7NuS bJIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mxpqEuyw4hz1MIOmCFCUGDiDhXbHwrRBQ37/cpaAH0I=; b=uCehPwAcrAZLcVART+Vms/MrHTgMMdnQJAdal1L9HEaewOJQst2Eth+E/z3npiFiZb VdrNXQ/qz8/TlWnRUx/Ej58Fc9SkUxBHY3v5X4FP912ADjWRfd03sl8dEC8y3Vsrw/k7 ap2+mEM3rmqds3Podn9NfFbbL1ADdZR89ERWUB3kqfRHYQloVjgZT841HDYN56aiuAqV ks4GhXFuZF82DWmxZcuFbbk3QzEjg2n/1EVX51LCiFZJlNXzB4HxGCTghvdoJ76QuvZE xxBP1EU6uivT+TRPG1uK/zlVH45sgXKtPXjwx7MkLav+Lt8G4DOylmkax/Tz9LuHjRxz kxcQ== X-Gm-Message-State: AGi0PubEhpOtVNBcvo3xRoKxvjpLpzBYIrkO2PGaGTOjpjwAQJCBJ2c5 bvaYuzPMizS1A0KGzFvZHEsHABLAHV7J5Vrw4fo= X-Google-Smtp-Source: APiQypKNDDjE1qbQ0Tstb0G1z70Wqmbm+WKa2kV2AUiBJJ03yqHjEV21oDzFl01Y3Kr2ZAlKST3/5gKEmbbvbhREGKI= X-Received: by 2002:a05:6638:4e:: with SMTP id a14mr8632020jap.108.1587050661664; Thu, 16 Apr 2020 08:24:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 16 Apr 2020 17:24:10 +0200 Message-ID: To: Guilliam Xavier Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000eddf1805a36a0622" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed From: carusogabriel34@gmail.com (Gabriel Caruso) --000000000000eddf1805a36a0622 Content-Type: text/plain; charset="UTF-8" On Thu, 16 Apr 2020 at 16:22, Guilliam Xavier wrote: > On Sun, Apr 5, 2020 at 4:02 PM Gabriel Caruso > 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 `__unserialize` 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 > Hello Guilliam Magic methods not mentioned in the RFC won't be changed, that's why they aren't mentioned. The reason is either: - Isn't possible to add checks: the case of `__invoke` - They aren't really magic methods, but an extension method implementation (as far as I understood during the development of this RFC) `__unserialize` and `__serialize` should be possible to add these checks, I'll take a look in the implementation. About `__toString`: this check is already performed in PHP 8.0: https://3v4l.org/jIg7b/rfc#git-php-maste r --000000000000eddf1805a36a0622--