Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114369 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5952 invoked from network); 11 May 2021 08:51:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 May 2021 08:51:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 010F0180211 for ; Tue, 11 May 2021 01:59:15 -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-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 01:59:14 -0700 (PDT) Received: by mail-lf1-f48.google.com with SMTP id t11so27479872lfl.11 for ; Tue, 11 May 2021 01:59:14 -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=MPUL3T4rkEj+veUMgumCSjmkO+AA9kMfRQXGV8e/1t0=; b=GtVowlC3iicsWU8kBXWjl1a/vAur8W7scHK7O9+QAFN1ThlsrzplJgNbrJFr6qaI9J BY/aK/Mx/UL8yqQRiyWeYV1P+/rQ1G13PRmeOzPw50NplFmk0a9z5Rb5eYYtxjwKx/rR 1fakHdEXZSAYGKC/JnBpwKk/73WhHzEKOZuQnlCcg7OL81W8KNaY1foYx3FLDpvsihxc eECgmlF/G8JW46X6HHeW7/Muww4ZyVKC9bIefMfUR0NncrPN3ldwvOJPkP0eC0JhN89X cBJy3RuLtiKH4wpUAIBHZTZaDfGfmNLOFuN3yl3Yz5W++/5diYV5s7haA0vTT+4HREMW pYZA== 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=MPUL3T4rkEj+veUMgumCSjmkO+AA9kMfRQXGV8e/1t0=; b=nINrq4AK35fqXX41r0CcKUoQ+TQnukN5cF3OcHfp1NRbYnJ9UApQKJvYRVtsApH7Gq Sn0P5JkeU5vn0PDKxSH9gvuOw2buvBvuAs7U+33iR5MJErS8w9fUVoPr0MUttNpcouC/ YVMVPYeWgq4tMVuTZ5xUE/V+OIObIZqiBy09/nT1TlFSI97+o+qOykvi4vKGe589oBDd CV31adAo2R+AOLbhtigwU21270MSDJhhPu9ZN1Wgj87hqFaBqzkyj40W8XJlno0kqkIa TqV6eC9mCBL6vOzIwQN3bo+fyCm6V+xvosK46DJTBVAb+Gy3984OMvMGWUbrBa3fl3Mx oRsw== X-Gm-Message-State: AOAM533oos/yw4DeQl3WPbMr7vOq1+y4vue6DTwOWcjHiEfT2i1VTU4P 0UBvGcy049aJu6edsM9m0ifzhuf1Zz0NItniq8k= X-Google-Smtp-Source: ABdhPJyga+Aqdl1pRVjn8KONj8SfBvu2TQnQeqB7PWrd69RJub9YbSvau7UlibTtBV+L8Gzukx9bvkRucOkgkyBsWhQ= X-Received: by 2002:a05:6512:2312:: with SMTP id o18mr19792840lfu.159.1620723553136; Tue, 11 May 2021 01:59:13 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> In-Reply-To: <1620635361.9147.0@gmail.com> Date: Tue, 11 May 2021 10:58:57 +0200 Message-ID: To: =?UTF-8?Q?Mat=C4=ABss_Treinis?= Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000a9f28d05c20a1bde" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: nikita.ppv@gmail.com (Nikita Popov) --000000000000a9f28d05c20a1bde Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 think we should allow replacing "{}" with ";" for methods in the general case. Regards, Nikita --000000000000a9f28d05c20a1bde--