Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109626 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5323 invoked from network); 14 Apr 2020 15:16:55 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Apr 2020 15:16:55 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3C9601804B4 for ; Tue, 14 Apr 2020 06:46:35 -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=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FREEMAIL_REPLY,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-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (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 ; Tue, 14 Apr 2020 06:46:34 -0700 (PDT) Received: by mail-io1-f45.google.com with SMTP id y17so13208580iow.9 for ; Tue, 14 Apr 2020 06:46:34 -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=G+qnD3zw54UmKvZdx0D/AwFE6knhr5OhuOxjbCK82D4=; b=loOOltjtSXygH6njfpqt25vYerE3ehWBz1sgemHjBxXT3zbF57mtwmtN+CQ7kAfpIA wXSvdNTgXUkintNf9uEyUiYllnGiR5q4tn/bQBfJeAj3LhRUzE6jvjU7f2YXvKvfyH+O 1XMh9UYZQGoslWAYCyQRUNKo1PTgJhYJH6uL6JmjvVdsfo/0XVQFefdJ/3NzMCXQys4z BpbXcEWKhHKID4mvi3y3GQKIh44XhzLaM2/ADJQaBovr/Jzk7badaGZsx2um8I1rjpsK QAoZzTPhMV++robLYWKqkMYeu4veExpuV85eTJN9g/HYW46GD3QTKUPmfXV+L2ph6iWM 8SSA== 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=G+qnD3zw54UmKvZdx0D/AwFE6knhr5OhuOxjbCK82D4=; b=IV8dommgo4JlwgDdMqeRRBVaCsVoImBNWt1YtkRJyfCF9jvX3JOw/3MoVel64xcqJr w+3DppZ+RWg83+ekeug+JLNavDwbYZv0sPCh8aa3zxm7utgR/vcNlEeEKC5Jyg8c5e4P xtelWWjhPG3UH9itgsG2nn3J6c22LZZ2KcacgMElJtrRETVBU58DKoLZv1BNoLKGdImX cq2vujoCJBo3e13WhgWNxK85hZczyqwd+Z9+ft1xWwOY6s7MsWceqF8s6M3vJ4oOEjVl b5K9elY0aPrZ4JQKZx9wJAHMsQKUNhD0TZdi33ba79BMgQ+WGxpxAt5cB60wqTRzKrvW vmlg== X-Gm-Message-State: AGi0PuZgNkolSWZLjP2TPmESO4OHz6B7w8QpPBJC6iEkebAwcqwYatg9 IlpAKCMfOf5cSwJ75S53cZWhAIICxVDx+fYyKTU= X-Google-Smtp-Source: APiQypJkMy1ThvrudEEQ+YYciTSwy26WjVVQ96lSwIf24mO6Cc2zv8Kfs62KyMERc2h/jpIapYv0Imviz9ak0pNtLxY= X-Received: by 2002:a5e:c64d:: with SMTP id s13mr7861992ioo.44.1586871992354; Tue, 14 Apr 2020 06:46:32 -0700 (PDT) MIME-Version: 1.0 References: <90F4B395-F010-4196-9C40-7896D4F3F2F4@gmail.com> In-Reply-To: Date: Tue, 14 Apr 2020 15:46:21 +0200 Message-ID: To: Nicolas Grekas Cc: Claude Pache , PHP Internals Content-Type: multipart/alternative; boundary="000000000000688c7d05a3406df7" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed From: carusogabriel34@gmail.com (Gabriel Caruso) --000000000000688c7d05a3406df7 Content-Type: text/plain; charset="UTF-8" On Tue, 14 Apr 2020 at 15:24, Nicolas Grekas wrote: > Hello Gabriel, > > >>> https://wiki.php.net/rfc/magic-methods-signature >> >> RFC and implementation have been updated. >> > > There are a few things I don't understand from the RFC, let me list from > the examples. > > > This RFC proposes to introduce the following signatures checks when > magic methods are typed: > > My general question is: what does this mean exactly? > > > > /** @return mixed */ > > Foo::__call(string $name, array $arguments); > > > /** @return mixed */ > > Foo::__callStatic(string $name, array $arguments); > > > /** @return mixed */ > > Foo::__get(string $name); > > > Does this mean we won't be allowed to declare __call($name, $arguments);? > > This looks against LSP to me. > > > > Foo::__clone(): void; > > > /** @param mixed $args */ > > Foo::__construct($args): void; > > > Foo::__destruct(): void; > > Is void going to be mandatory now? This should be specified in the RFC I > think. > > If it's about to allow void where it wasn't allowed, I'm personally not > convinced it's a good idea to open one more code-style war on this topic. > When there is only one way to declare something, there is no need to come > to any agreement about the code style. That's a win. > Hello Nicolas No, *nothing* is gonna be mandatory. As per the RFC: > This RFC proposes to introduce the following signatures checks when magic methods are typed: These checks are only gonna be performed when you type your signatures and *only when you type*. So, your example: `__call($name, $arguments)` will work just fine, same as if you don't type `__clone` with `: void`. Is there a better way to phrase that in the RFC? > > > Foo::__isset(string $name): bool; > > Foo::__unset(string $name): void; > > Same comment about LSP, but also about the type: isn't it allowed to have > integers as keys? How does this play with strict_type and array access? > Thanks for raise this. Nowadays, you can't: https://3v4l.org/pPJDt. But, if you call as a method, yes: https://3v4l.org/0VmYQ. So this should be documented in the RFC as a BC Break. > > > /** @param mixed $value */ > > Foo::__set(string $name, $value): void; > > > Is the return now going to be mandatory? > No, as explained above. > And the BIG question: is all this worth the BC break? > My main motivation is to make sure that developers are using the magic methods with the correct type, nothing else. If everyone then agrees that not having these checks is better for the language, no problem on closing this RFC :) Let me know your thoughts. Thanks, > Thanks, > > Nicolas > --000000000000688c7d05a3406df7--