Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114326 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 52309 invoked from network); 10 May 2021 08:42:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 May 2021 08:42:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2F6AA1804E3 for ; Mon, 10 May 2021 01:50:18 -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-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.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 ; Mon, 10 May 2021 01:50:17 -0700 (PDT) Received: by mail-pf1-f175.google.com with SMTP id b15so13157910pfl.4 for ; Mon, 10 May 2021 01:50:17 -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=yg2AQwacoryMeGAi2s6ugvZrDMt4+WsjQKDenYEtxWc=; b=G88oSQGf79f3Wq/onKFNqtBdQhenfMxAB/mYOjqse8LrGiKuqGVCJrNokG8G04lt96 BuUfT7HhNCDD/cd0grYhLxUlnKzakuuKfqTEiQRC62DxLT9yRHCaEH9lm/JD1M5RXRt6 5K1cB4lrDTNJV8mZszbKOb4+5pS1wCOQ8uwyY9mFcSBF5zcw07pf1FxDsd7hsI6CU6ZE SC9Gzup8etpMO2/v2kYUWHO8STKvFksojI9HXEwh5uqiSdYoMIGXCsmt4jeyVzcd9b27 rSS/YENCJNQyDFURFqGKgjyTMQQWsu9kjIae1sb4GQh+szb3wDpMiJGOMxE7NulRyfe3 AGPg== 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=yg2AQwacoryMeGAi2s6ugvZrDMt4+WsjQKDenYEtxWc=; b=Ed4MJRdKW26FDgzi1km5JmWK+b5fArFisFk2n4+EELZymeRXsAsasm6OzUtQGPeaKs m+zbclMqBW94IwcGNG/KPxbkdvi9WZCmfSN1TQbL41tUH6zcn8VywD/EIBXws9avx9ME 76o/O9bvAD27OkoqU3dyHCgGYNXQu+F3WZPQ/13Vww55K81MV83yQYsaWt7HmZdHN3EE +piT7QVa4K2DS0r0ngAUp/5W7SZmItwzCJWKEA6XajYsjmM2/m995dfFIpKxUvmOGpM9 KnDWiES7Id/JT2545mE2TLuqTtG7gxA/al3JivxLpKO668ZVyq+HHJ0MJpKg3sxsTt/O AGrw== X-Gm-Message-State: AOAM533szdUIYwnEVac9SllOJSoJAX4QIGjE1zcZXo1f8mrX+CyhyUYQ 0/ZSbDD1DlPH3Pk2O+S+JBBtd50j9pWIrx7cAdA= X-Google-Smtp-Source: ABdhPJzYocu3ECxFwlupA1HK1JTH6nmtDpZnmpF6QPlc+dIe2QZ+S1s83rOr/XRtLsanL1u4NLU+9XrY+Q87KShaV3A= X-Received: by 2002:aa7:9a81:0:b029:28e:b12c:9862 with SMTP id w1-20020aa79a810000b029028eb12c9862mr24298048pfi.51.1620636615271; Mon, 10 May 2021 01:50:15 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> In-Reply-To: Date: Mon, 10 May 2021 10:49:39 +0200 Message-ID: To: Marco Pivetta Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000c368a005c1f5ddb7" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: mrtreinis@gmail.com (=?UTF-8?Q?Mat=C4=ABss_Treinis?=) --000000000000c368a005c1f5ddb7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Marco, I am not sure, that's why I am asking for feedback. I have been converting a ton of code to use constructor property promotion and the absolute majority ends up with the method body being empty. I reckon this could be a nice eye-candy to have, however, it's nothing more than that. Another point to be made here, as far as my interpretation of PSR-12, the curly braces occupy two lines for methods with multiline arguments. So for whoever follows PSR-12, it's more like this, with brackets just dangling there across 2 lines. [...] class Foo { public function __construct( private Bar $bar, private Baz $baz ) { } } - Mat=C4=ABss On Mon, May 10, 2021 at 10:31 AM Marco Pivetta wrote: > Hey Mat=C4=ABss, > > This already works by replacing `;` with `{}`: https://3v4l.org/tN4HM > > Is the change in AST really necessary, considering that? > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > > > 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 >> >> --000000000000c368a005c1f5ddb7--