Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110833 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15799 invoked from network); 3 Jul 2020 11:53:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2020 11:53:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 24CBB1804DC for ; Fri, 3 Jul 2020 03:43:06 -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-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.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 ; Fri, 3 Jul 2020 03:43:05 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id t74so18219253lff.2 for ; Fri, 03 Jul 2020 03:43:05 -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=cacX2xUktBgAcj+UI6TZXcy2U07c4viPy2qRqZaMYoU=; b=nVOTescK06n/KfqSBxjv+15N3MC+R/9w0ueI2F03z66yxYFdfQauvAXIVFkY026ebO d2lBCUfweNChVqEsC6bHADd9HscKQRtNEjZb4HuB2jEPOJStw5Mgw/EoN6LpYWEF8hUV +txD4hXIqONxpmOwzvTeaUJheLkXTMmr6DxYt7Gt+KesPTSDxRDdlXBnWouTeFqUvOrX WtHSIh1TD73rm8ygurp9exTu4XVGNX+eZAvUcpzQlyH2YerjSpEX8/mnrE3Pfe7juvME ZCN2ElIHJMtz6Nw6dnVa9SKPbHb2sRL8nptX4UagqMZ4jcyDKjTUFyUYmV0aQlZmji1X /QqA== 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=cacX2xUktBgAcj+UI6TZXcy2U07c4viPy2qRqZaMYoU=; b=i1IdVp3UHSqksBFYZOlZvCTzJbISp6tK6mjEozh0sQJNCIgnoQ3vAeOg+VlrZ6ZBI7 /ZGpkYE9B9DCE2dzLwjzGKoi4RvGb1sqV+GD5t5+YNoj/txxC0S2/g9Kl/HRqD7eQ0pq lA/ZSvB7s3wlBhpnPjva61e5EHGEa3P0cfY4bUIWKYjIyORqmHWWycRTfTdeoXeufoKc xmulSs7k0azxD54sfCb7Ao5SAlzpyRlKer0Nx2gXO4bqSpuVdVgX2SozSAPJupuvIGGG oDIR1HJfGg33Pis+BEmqGLfga/DmxTJE7oTnQZi5PVIdyNteOLoTnSrQJPC7IVLZ+H1y WQGQ== X-Gm-Message-State: AOAM532MqjXR0hdHZRfL7AfT+6FrffHOddXyaKhun04kasJErwajaNng m6ptSvNSSJ2pvGVOlXe53jb18bhSBUUxVdQc5Ow= X-Google-Smtp-Source: ABdhPJzCaUjL5KS2qCs0YRZXxz8PLnQ6ZCp3H82Gz0MGWHqDZjtwwCM2G8hgvoU438uYCTZTt8lXVfYURrM8sRmFpGA= X-Received: by 2002:a19:c389:: with SMTP id t131mr8131713lff.130.1593772984158; Fri, 03 Jul 2020 03:43:04 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Jul 2020 13:42:52 +0300 Message-ID: To: Nicolas Grekas Cc: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000092cbf305a9873072" Subject: Re: [PHP-DEV] [RFC] [VOTE] Make constructors and destructors return void From: benas.molis.iml@gmail.com (Benas IML) --00000000000092cbf305a9873072 Content-Type: text/plain; charset="UTF-8" > > I think that Larry's and Rowan's replies on the original discussion thread >> really well explained as to why it makes sense to allow an explicit `void` >> return type, so I'll just quote them instead ;) >> >> Larry: >> > I see this in the same category as __toString(). >> > > I read those yes, but there are subtle yet critical differences to me: > > in PHP < 8, 1. the return-type of __toString is already enforced by the > engine (just not by the type-system, but the end result is the same) and 2. > it is already allowed to add the "string" return type to the method. > > for constructors/destructors, neither 1. nor 2. are true: they *do*not* > allow any return type and they don't check the return value. > > This means that the change on __toString is mostly transparent (only the > exact error message is different), while the proposed change is not. It > will have a cost for the community, and my opinion is that this cost is not > worth it. > Well, for `__clone` neither 1 nor 2 are true as well. But as of PHP 8.0 it will be allowed to declare an explicit `void` return type on `__clone`. Thus, this will have a higher cost for the community since this behavior will be quite inconsistent with constructors/destructors which do not allow to declare an explicit return type. > > Any constructor returning non-void right now is Doing It Wrong(tm) >> > > That's precisely what I read as "gratuitous strictness" (no offense to > anyone, I respect this opinion.) > Especially when this might become "enforced". > That is rather subjective. Adding an explicit `void` return type allows to clearly show developer's intention to not return values from a constructor/destructor. While some people might not see any value in this, I personally do (and many others too). Moreover, as mentioned before, adding an explicit `void` return type causes the check to already be done in PHP 8.0. Which otherwise implicitly will only be done in PHP 8.1/9.0. > > >> Since some internals told me that PHP doesn't follow semver strictly, it >> would make sense to enforce the check in PHP 8.1 already. >> > > I invite you to read https://wiki.php.net/rfc/releaseprocess where this > is detailed. > Here is the relevant excerpt: "x.y.z to x.y+1.z" => "Backward > compatibility must be kept". > > A dedicated vote in a specific RFC cannot overrule this policy AFAIK. > See Nikita's reply. But if more internals find this controversial, I can close the secondary vote, that's okay with me. > Thanks for your answer, > Nicolas > Best regards, Benas > --00000000000092cbf305a9873072--