Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114381 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44424 invoked from network); 11 May 2021 13:51:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 13:51:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C920B1804E3 for ; Tue, 11 May 2021 06:59:44 -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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 06:59:44 -0700 (PDT) Received: by mail-pf1-f177.google.com with SMTP id b21so9041455pft.10 for ; Tue, 11 May 2021 06:59:44 -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=t0CZgSDOjqCLARNyl/HfafkS492eTZAJWPJCIMzjTuQ=; b=BCd/pnZjoGhjflsA/V8ZVY5JXUcBpxaI4k6qRISNJFyPi2FGVKUti8t1pNshp8UpHg NRYco2ekr/6NbV8Dm2PknZwQuT1nyZhdp8q1DcXZf6nTvINUHFd0PAH3IQHYxxEknU6F vm4+evvg16ltoXATwEqsJ8RYT2pFTlHpOnIiefULNUu9gwgO4fMyJKhp3PUgedJPWqZP fkJHtksmkFnIWhX0Tf68LYBQ8PSsvu0j2l20uV6+Zn5yJObzjAAY72/AT0NUW8ZAaDvz 5KyOD8EGVbgHzI1dsf0+izXvADTnHVne8NiUJbAmFpfeDpZShJwn4n211iSyhu7ptDzZ kcAA== 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=t0CZgSDOjqCLARNyl/HfafkS492eTZAJWPJCIMzjTuQ=; b=WF01tmGVtX7X+0Zkq43jliO8P8GLg7FUW0tNoew2dUDHHkSR0c3W3y1Z6lHGEEd8Yt Bbe6DFnMlbma69IwEV7Zk1yiIK4T2KWQ2ZQ8otYL49ZVbpk9uGeWXJ+lQkOl3PTN6Dzd G/dVgyUSJ56ua78896Ze4FEu8gjgi+9vXOjc/OjcnY70atbVANiKqQLKF8CK7FlAt/hp PjgdNvCiW+CdAKGXinJfVIeqy4qyqiTMqjNWyPBX8GXwwliP+eyFO0jYUAuAdioiPVKN 0Y5smJb3rQrBSk+0R0+MErrzIT742hvXamCKrFt+g1ECnvyRZ4yFH3PPhsqvHDyC8igb ZV2Q== X-Gm-Message-State: AOAM533c2lTIPYE0KhICgakYFlPy6uvYwRCT8GpCjQy8iN8C1sVtmlg7 ErvcIBVocY/D6lwQ8rNCv0JlrtCXsWV6jV0cg1M= X-Google-Smtp-Source: ABdhPJzMf/e1Yxia9YWT6Pq63KBSw2l6IviTE+wDvhPHEblr0hcUy4atu+V+YSemEQVdiScdZB/0k3LeBj9MhGtgY1s= X-Received: by 2002:aa7:9a81:0:b029:28e:b12c:9862 with SMTP id w1-20020aa79a810000b029028eb12c9862mr30984725pfi.51.1620741581607; Tue, 11 May 2021 06:59:41 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> <1620728274.110454.3@gmail.com> In-Reply-To: Date: Tue, 11 May 2021 15:59:05 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000003e95d105c20e4e24" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: mrtreinis@gmail.com (=?UTF-8?Q?Mat=C4=ABss_Treinis?=) --0000000000003e95d105c20e4e24 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Oh absolutely, and many thanks for doing the code part, Nikita! I would propose leaving this open for debate till, say, 15th of May here on internals ML to gather more input. If there are no super strong arguments on why this should not happen or go to RFC, I will draft a RFC and from there, the usual process applies. - Mat=C4=ABss On Tue, May 11, 2021 at 12:41 PM Nikita Popov wrote: > 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 th= ink >> we should allow replacing "{}" with ";" for methods in the general case. >> >> Regards, >> Nikita >> >> --0000000000003e95d105c20e4e24--