Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114372 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15807 invoked from network); 11 May 2021 10:10:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 10:10:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0FA4A1804DB for ; Tue, 11 May 2021 03:18:00 -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-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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:17:59 -0700 (PDT) Received: by mail-wr1-f53.google.com with SMTP id m9so19565110wrx.3 for ; Tue, 11 May 2021 03:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:message-id:in-reply-to:references :mime-version; bh=VePaUkLzk2BpFWZJtBUNmCMGVt4axkvCi1ot1DKxKrc=; b=hapEzNl6aHMfcYpfFb06gZ8sHp/6A+ipcccAyu9wgetmQ5MKsof4xMVxH2sf2KoYvn bpjx/8qXwLL4ScKJ9BEIg+LAUJkRWAxNtluvy1tG0b10COliHj1cfvoheoO+/UvlT87B lFowidTB43UWrxgfWV2ie/DDUL9qSZbl5VCWQ3wQNScDhQ9fPicZHQR2W0Of1SYdljKK tk6KjgrYRsf5kaZ/lSib0s7njAzmPRSwFf3jtgWQyBj0405o/I38ur8rzRgQPwSw02qM SU81rvhiXtawW3XQAdxMMDmCMxLYmy3wjxE4KLHIkBPHvTWWzm1VLgGskd+oOVEcMdE6 wV8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:message-id:in-reply-to :references:mime-version; bh=VePaUkLzk2BpFWZJtBUNmCMGVt4axkvCi1ot1DKxKrc=; b=c8bYKBFFZm65SxbICutYw7L/VJ+N0S2Cyi97LtHCo/0n034AjBB2jgrnQIB8F/JKUH EKitvzoe9giwjrHgkYgeconLlWZ5h6Wg6REEOa+e2d0NBvPGNAGxxdhu2r099/7kacKi PWPdjT7rCDV6CR2pSuU3cFBTIHVIwVS7C/st50fAtEZaPjAy7I8E01hOcH1EX6vj7OOq BI9UdGuMPj+g07AJVPr5xIaczU7+UBKpTE8gOeqCMqkXUUgdfoRBrdjvojQd65MQvmV3 ZdMBiHeAfuGi71mqcMTVXU3XnODDL7K5d4Dmc8Ax1owSyfSYwzfsJtkoCUyMY0ZfkLxd AE6A== X-Gm-Message-State: AOAM530H29s9amymlAmSDkUOAfAKfWEfqYtO7l8O/STq472fGXJN+2yJ JnxaXz8WRrOl/mAIQgfhtZU= X-Google-Smtp-Source: ABdhPJxaC2u3/KjObCXsnYv/J0qrPdqi1pqhLl6Su9wOS6NNW4V58I4S8JOPAYqpQXjpesiRu8pHRQ== X-Received: by 2002:a5d:5186:: with SMTP id k6mr37311340wrv.335.1620728276129; Tue, 11 May 2021 03:17:56 -0700 (PDT) Received: from [10.15.1.244] (36.49.14.37.dynamic.jazztel.es. [37.14.49.36]) by smtp.gmail.com with ESMTPSA id l21sm3053079wme.10.2021.05.11.03.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 03:17:55 -0700 (PDT) Date: Tue, 11 May 2021 12:17:54 +0200 To: Nikita Popov Cc: PHP internals Message-ID: <1620728274.110454.3@gmail.com> In-Reply-To: References: <1620635361.9147.0@gmail.com> X-Mailer: geary/3.34.1 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=-Eeou0dEnmNbyl/zET0SV" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: mrtreinis@gmail.com (=?UTF-8?b?TWF0xKtzcw==?= Treinis) --=-Eeou0dEnmNbyl/zET0SV Content-Type: text/plain; charset=iso-8859-4; format=flowed Content-Transfer-Encoding: quoted-printable Yes, just to clarify the scope of my initial proposal, this should only=20 ever apply to promoted constructors that have 1 or more promoted=20 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=EFss On Tue, May 11, 2021 at 10:58, Nikita Popov =20 wrote: > On Mon, May 10, 2021 at 10:29 AM Mat=EFss Treinis > wrote: >> Hi everyone, >>=20 >> Since constructor property promotion is now implemented, and it=20 >> 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. >>=20 >> Here's an example of how this would work: >>=20 >> > namespace App; >>=20 >> class Foo { >> public function __construct( >> private Bar $bar, >> private Baz $baz >> ); >> } >>=20 >> Some notes to this: >>=20 >> - Since this is similar to already existing syntax for body-less >> methods, parser should not be affected that much. I hope. I really=20 >> 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. >>=20 >> Thoughts? >> Regards, >> - Mat=EFss >=20 > For what it's worth, I've received the same suggestion from quite a=20 > few people. There seems to be an intuitive expectation that only=20 > adding a semicolon will work in this case. Personally, I'm okay with=20 > allowing it. >=20 > If we allow it, I would restrict it to specifically the case of a) a=20 > promoted constructor b) which has *only* promoted parameters. I don't=20 > think we should allow replacing "{}" with ";" for methods in the=20 > general case. >=20 > Regards, > Nikita = --=-Eeou0dEnmNbyl/zET0SV--