Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114334 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71008 invoked from network); 10 May 2021 10:24:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 May 2021 10:24:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B66B11804CC for ; Mon, 10 May 2021 03:31:33 -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-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 03:31:33 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id z9so22559208lfu.8 for ; Mon, 10 May 2021 03:31:33 -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=1a4tWuE7ER8Kbz318/ZqG5XMt9zKdmujTMPRbU4ohAc=; b=rJ0QDd8IhBMoNg4cct35xyK5OD6TL9y/08rCK87lFgvmbjoPulUFx2+Ve4ZIDIfhCr bhwRl5t7foRtS+NSNRWn3ykkjhPQnIsqaAEhC9X67nVqX4f8AYYJJam6pjj16pJv5PEV XgdiALuIu0KO2DBZE0exzV0/fv0YdaYf+0OfjUDy8jCUccj39T5hdFU5UIeFTsBSEk75 65apaU3X0k+pdtNAtz3EMLLnvqim0TmJfzfGEpdM9cZw3wkfngUSFNSahfcKGk+IyOjz A86Jfzthxt9dfPoPdct8JQVY7w38lJDvWHtCeAZWRzOvANFaZDmh9J2ikizJBjjPVjuB nM7g== 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=1a4tWuE7ER8Kbz318/ZqG5XMt9zKdmujTMPRbU4ohAc=; b=GsZMbhBbhzyasHywzyHkUo6y4zgYISPjCQd51Fc50F79KR25zaHWg2S8c0EJZ4S/s4 BaWciXUjEm6I/K02RMjQIIX3je5E+o9moyd5NrSkeh3a3GiT5NnSVzACAtM/Cr60vAGE 9qwJEZcfuj2NeJdft99cQrOfpqxY2sVcVBFtPZblrLtoT23Ezmxh3KRkUkRgHAHTzLeE ibHa0fyzY4+nUA+93cVu/Bwq98eaJlMieBNKbZVoI0QOlVcjyDuyzZ+bjVVsTQ2RpIhp 06L9LMURUfBgxb2fyL0p0HwXBLcFrWYN/1ZGqquxYCKUNBO1j4wg5lSC0BVvwhaCsB7m qhVA== X-Gm-Message-State: AOAM532/eL9C6w0Lh49GSaKCMJJEDDk7kDVVA8Jdk1EjHo41ZRCX10XQ 4BbRbvM8mgQuTMeC+SUCIHdMs42Btr39tNgrvA== X-Google-Smtp-Source: ABdhPJzXokulY4MPHOKLWkZGgVmEmiqj2FB6eWPpueKNHaLjCDvSOvnfrNtGOJXhF4zLtm0i41/3CVydvD637iYtxZ4= X-Received: by 2002:a05:6512:34d4:: with SMTP id w20mr16253067lfr.124.1620642690246; Mon, 10 May 2021 03:31:30 -0700 (PDT) MIME-Version: 1.0 References: <1620635361.9147.0@gmail.com> In-Reply-To: <1620635361.9147.0@gmail.com> Date: Mon, 10 May 2021 12:31:20 +0200 Message-ID: To: =?UTF-8?Q?Mat=C4=ABss_Treinis?= Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000dc2a5e05c1f7474c" Subject: Re: [PHP-DEV] [RFC][Draft] Body-less __construct From: guilliam.xavier@gmail.com (Guilliam Xavier) --000000000000dc2a5e05c1f7474c 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 > > Hi, To me `;` means not "empty body" (that's `{}`) but really "no definition, only declaration" (or "no body, only signature", and also "no code executed"), i.e. an *abstract* method (either explicitly declared so in a class, or implicitly in an interface). Granted, property promotion is already special (cannot be used in an abstract constructor), but it can also be mixed with non-promoted parameters and body, so I feat that your proposed alternative syntax would bring more confusion than convenience :s Regards, --=20 Guilliam Xavier --000000000000dc2a5e05c1f7474c--