Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114373 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19241 invoked from network); 11 May 2021 10:33:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 10:33:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B05F61804BD for ; Tue, 11 May 2021 03:41:12 -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-Virus: No X-Envelope-From: Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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, 11 May 2021 03:41:12 -0700 (PDT) Received: by mail-lj1-f170.google.com with SMTP id y9so24514512ljn.6 for ; Tue, 11 May 2021 03:41:12 -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=H5FblzqomakHSdqRjlDNEnAtziliETDUMK7wWj9tH88=; b=Xlg0Mcy/81/kWVAnyT3q+GlU9e1PaLiPCjiErwuDlSfuOmFzAWvrVVCrR2edAGH7pz Z/guNeSfHOqXilqW5Yfu/de1Kf4optewJ3E2pP/6InbBLlArHNvLM0kJX21wBUqptEJP 8zRBQe9lgdGte/TcqUhAOhuA4Q7lnOosfGAmij4R5g+jOoXiECmwPM4cH5vWGKZXCkS+ 6gOiXNDvwotTm5V+FGTqYgnAsuIfG4gcFAdQ3svSC8gzYhOfxlAXJE6JHywFTfgrA1Io EMxCs9ChrDsy0Febe4M8k4IX1pL+p6BL8cNu1+ccRDNoZWq+WikgZ/DUqnQF/+H39SKA UBOw== 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=H5FblzqomakHSdqRjlDNEnAtziliETDUMK7wWj9tH88=; b=MsAmcyZbR6ayX4Gy58Cj7mteKclTio1LNc981a3HTtvwj/82K9OqB9lGVQiXjgoVAr vikQ/HrL/FW7w7JKyQ1jH194hZ48FgnyuEthyMS38EXKEq4emWqwDSXBsRYpC5JWCRQ4 aWQn8cnLwOV7ciBVI0sIO4CQCknBqrteuzuLAcYdbR99OMccN3sM+nu9bIcziwXHXtbn pzlyThqzgkgcTo1fLzKfo3hM3Bjel33N1q77j+WO/QPhWiaTWQwLgNdg9I4HhjT2o1gp vRlCQ6o1an+zLEX8l4yGMr/0n6CoIVhB7GqG4752D2N90WshHz6l4eXGdFzV1732lwgb FlqQ== X-Gm-Message-State: AOAM532ZtpJSdftifRDTw3fbZx4HyseaWadVIMoPa4xvD9b8N6GTTyf2 nqVcgmmG+NrUnr726NCUKn4Qo2GVw0sqLyCaiu8= X-Google-Smtp-Source: ABdhPJxYnnRemCiuenj2Zcf3+hXB6I2r4VYNocD5LZeKanHotYnbupoQ2quAP0jBCIXPra/WjdIxtraJbqPUn6NHIFA= X-Received: by 2002:a2e:8e3a:: with SMTP id r26mr23750205ljk.244.1620729670606; Tue, 11 May 2021 03:41:10 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> <1620728274.110454.3@gmail.com> In-Reply-To: <1620728274.110454.3@gmail.com> Date: Tue, 11 May 2021 12:40:54 +0200 Message-ID: To: =?UTF-8?Q?Mat=C4=ABss_Treinis?= Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000004b226305c20b88ca" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: nikita.ppv@gmail.com (Nikita Popov) --0000000000004b226305c20b88ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 11, 2021 at 12:17 PM Mat=C4=ABss Treinis = wrote: > Yes, just to clarify the scope of my initial proposal, this should only > ever apply to promoted constructors that have 1 or more promoted > parameters, and no not-promoted parameters. > > These would NOT be considered valid: > > public function __construct( > private Baz $baz, > Bar $bar > ); > > public function __construct(); > > public function __construct(Baz $baz); > > as well as anything not related to __construct. > > - Mat=C4=ABss > I've put up a quick implementation for this: https://github.com/php/php-src/pull/6972 As this seems somewhat controversial, I'm afraid this change will have to go through the RFC process. Nikita > On Tue, May 11, 2021 at 10:58, Nikita Popov wrote: > > On Mon, May 10, 2021 at 10:29 AM Mat=C4=ABss Treinis > wrote: > >> Hi everyone, >> >> Since constructor property promotion is now implemented, and it looks >> like it could become a widely used feature, I am proposing a small, >> cosmetic change in syntax for constructors in concrete classes to do >> away with empty constructor body. >> >> Here's an example of how this would work: >> >> > namespace App; >> >> class Foo { >> public function __construct( >> private Bar $bar, >> private Baz $baz >> ); >> } >> >> Some notes to this: >> >> - Since this is similar to already existing syntax for body-less >> methods, parser should not be affected that much. I hope. I really have >> no idea. >> - Syntax would be optional - meaning, you can as well continue using >> empty body, just that in this case the body would be implied empty. >> >> Thoughts? >> Regards, >> - Mat=C4=ABss >> > > For what it's worth, I've received the same suggestion from quite a few > people. There seems to be an intuitive expectation that only adding a > semicolon will work in this case. Personally, I'm okay with allowing it. > > If we allow it, I would restrict it to specifically the case of a) a > promoted constructor b) which has *only* promoted parameters. I don't thi= nk > we should allow replacing "{}" with ";" for methods in the general case. > > Regards, > Nikita > > --0000000000004b226305c20b88ca--