Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110573 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 78424 invoked from network); 16 Jun 2020 10:40:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jun 2020 10:40:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AA2C21804F2 for ; Tue, 16 Jun 2020 02:26:21 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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, 16 Jun 2020 02:26:21 -0700 (PDT) Received: by mail-lj1-f175.google.com with SMTP id n24so22591012lji.10 for ; Tue, 16 Jun 2020 02:26:21 -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=fo06zja9kod5dZwq+rnwJ3IIj4bvhKbXSveT9bcejkE=; b=HW2JKkL597fnatvKyULgLYOyDdE9MRfDa3ZPwgCT7ieRp6MM7hlkZYhiR0q1Q9bqK3 fLFE2E7z7+wtlnhW4G33SVSWJjL4NeVLi/pMXadGHZbYFxqoFfDkQX2caiJXsAvcM3Fx y6BllK+aC7qXUrsF0+bdw1uoIA5DGHy9cVtRzlNsKEksYeXYHDWvZXPaVbOKRHdLDtfJ S1DYq1gokUs/FrbZI/nK2bkIzB64CF398uOfpE0zk6+3eQXw+auk/9tm+HHlY84hYqPc 66O0xhy/hfL4cc9D24jCKAI5pmzqPFDM3D8oWWPIgsj9Bi/I7KWxAyRmR1iYgfx7LgYV BHPA== 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=fo06zja9kod5dZwq+rnwJ3IIj4bvhKbXSveT9bcejkE=; b=TxqclFKLSiC/M902eResSx8doDzjj+yPXhi4JiBcQp5/okCWdjzsPiEHO6y+aapNSg L1pc4JfWSWvEkwxCGXZJ07qX+zU8a/TQ7u2slGd4x8jlmS2P4E/GHlRkYhWOdvVlHMEx 5gFs/rq/WilcvA7rhmyj/X8c99oaAYgK84/FBdJj1IAnCtCPJg3VA8nIrs2dkBxRtl3h f0Pn5BFbcTh8Ld/9bGqJBrdYNzQ+bEuebMtcaUy4ANTnpI0S4EWa1V1nBkzlZvlpOLoX +9CH7g/5occZQDii+1bdYGbBu8apEEfp0luyXljbVcUnFGh+hkqceY/81K6kQfJksUCU ebUQ== X-Gm-Message-State: AOAM533oBHz9UycbTMELGDOfkMbduSCotFZE4nOQKsQjfDOd/IZY2Ygo QOVCSd4sfTTdgzoxWcBe4Z1AXxvRPKjgwHHZAYA= X-Google-Smtp-Source: ABdhPJyT1oXwn8O0l2/jsIxkce5nQGTXdgZHuyn/gQFnyH7DG/90MHrOWhgpLhX4bC5u2Rp3Eeo7KdJGveTuUo+oPi4= X-Received: by 2002:a2e:98cb:: with SMTP id s11mr933154ljj.402.1592299579601; Tue, 16 Jun 2020 02:26:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 16 Jun 2020 12:26:07 +0300 Message-ID: To: =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: "G. P. B." , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000d1752e05a830222b" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Allow void return type for constructors/destructors From: benas.molis.iml@gmail.com (Benas IML) --000000000000d1752e05a830222b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey M=C3=A1t=C3=A9, On Tue, Jun 16, 2020, 11:31 AM M=C3=A1t=C3=A9 Kocsis wrote: > Hi Benas, > Overall, I'm very much in favour of disallowing returning a value from constructors. > However, I think the RFC should deal with the return value and the signature validation > in the same time, so that we can vote about both, since introducing the latter check > is not just a bug fix, it's a substantial change IMO. > > What I would like to avoid for sure is that the void return type is not actually enforced. > (Offtopic: It seems that the magic method signature RFC exactly does this, and I'm not > happy about it. I'd welcome an amendment RFC to fix the new inconsistencies). Since there was a second PR already in the works on dealing with the return value, I wasn't sure whether it was a good idea to implement that. But, I'm happy to join forces and will contact the PR's author :) > Furthermore, I personally also like the concept of an explicit return type declaration for >constructors, but Nikita's earlier argument against (that most languages forbid the explicit > return type) makes me think. Anyhow, this counterargument might be worth to add to the RFC. I should have emphasized more on this but PHP constructors aren't like any other language constructors, since they are normal methods that can be called by simply doing `$object->__construct();`. I'm not sure if any other language allows you to do something similar. > And regarding the last section of the RFC (Backward Incompatible Changes), I'm not exactly > sure what you mean there, but since constructors are exempt to LSP validation, I think > it's ok if a child class overrides the parent constructor with a widened return type. > > Regards, > M=C3=A1t=C3=A9 What I meant, was that since no return type means `mixed|void`, you can't do the following: ``` public function __construct(): mixed {} ``` But yes, it is allowed to widen the type from `void` to no return type. Best regards, Benas --000000000000d1752e05a830222b--