Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109878 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72799 invoked from network); 28 Apr 2020 16:44:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Apr 2020 16:44:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A8622180088 for ; Tue, 28 Apr 2020 08:17:41 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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, 28 Apr 2020 08:17:41 -0700 (PDT) Received: by mail-ot1-f50.google.com with SMTP id g19so33180180otk.5 for ; Tue, 28 Apr 2020 08:17:41 -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=M5EoyTSK8Jiskah1+xIYCI7NFwgX2YwPuiwdCorJPsc=; b=mNeJACxG6z0vmxE8fe8iFP3V2mJIS8FGj8XbdONvZjK2PkjH6hSjm8WbM1yxxrKBKb pDcRc6QpNJZPyD29UlgbJgBSh+c2lXBFLO8ZE+wgpmwif6LCJi2f27BC+PsowoRtUZ90 nDCXCLqjqWNFbWq/ENWe5mSKXA0X2QqhaKQT2gsUc9ZoPUIVzVJBMT5A/GJtzZyH9Mot 7ao+ZRKvk6cMGT+5cvA1ZC/JNBwLWuSWEydBS1jpCyWUG0YTaOERkyAF0/4yuUxAYt41 KEDosiycZ3deKfucAApAUIJnigz9M+c/B45lv2K7pxOoRqP+aDv0L8mRdlkxAZlC5aJC QTQg== 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=M5EoyTSK8Jiskah1+xIYCI7NFwgX2YwPuiwdCorJPsc=; b=A8dbkBfs88EQ6LhX8yWz4q9wKbBMToIMxn24vMbh8vS8g2ZStNeuC/3O7cmfBaslVG i3zRfdpNyxy0YNnWQCErSEkBIkNW0qpGJvKJbM7hl2rMisF/RIyHMj+iwmvw0fEkr6sx Nu4P1jENxF4dVyNZalks6ShPRTWLNW5dsPD6xVr4nmtlX2DxFsHRnPqpZf0OSrvwvOOQ uId3Ebnx5Ec8Ha1J+5ugr3aQHk7PYQ29DxJdnH804rF6xUiCvKN6/LqWteNUeALK14CL iJbxLACqMHzLMueXTYx2ewg9ABQ4fKFue1eLSPdZcpRGRIJPMBKN5OIZex4Vq+cjRrS9 927Q== X-Gm-Message-State: AGi0PuZuxHQyY1w1MEjoolp2z7+0wJnzfgURvGaQOPDckKTEa5CTY/eZ pw4zK4Aul9WbhN5ObxJuqkG+vD3GWjx/eMz6hBo= X-Google-Smtp-Source: APiQypIGJ2DOotqr3pXKxEkethhnkRVcBhUZXUp8BpOlTSicjvxZKBRluSUFpffTcscNW6nHEL+Yhgu4/H6Bx655GPE= X-Received: by 2002:aca:f2d5:: with SMTP id q204mr3260054oih.98.1588087055085; Tue, 28 Apr 2020 08:17:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 28 Apr 2020 17:17:22 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000ca749305a45b54ca" Subject: Re: [PHP-DEV] Re: [RFC] Constructor Property Promotion From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000ca749305a45b54ca Content-Type: text/plain; charset="UTF-8" > On Thu, Mar 26, 2020 at 2:30 PM Nikita Popov wrote: > > > Hi internals, > > > > I would like to submit the following RFC for your consideration: > > https://wiki.php.net/rfc/constructor_promotion > > > > This is based on one off the suggestions made in > > https://externals.io/message/109220, and some existing discussion on the > > topic can be found in that thread. > > > > The primary motivation for this feature is to close the currently rather > > wide gap between the use of ad-hoc array structures, and the use of > > well-defined and type-safe value objects. The latter is what we want > people > > to use, but the former is, unfortunately, what is *easy* to use. > > > > As it looks like the Attributes RFC is going to be accepted, we need to > consider how it will interact with this proposal. I've added an extra > section for this: > https://wiki.php.net/rfc/constructor_promotion#attributes > > The problem is that attributes are allowed both on properties and on > parameters. For promoted properties, what does the attribute apply to? My > original suggestion was to make it apply to both the parameter and the > generated property. However, Benjamin pointed out that an attribute on a > promoted property is almost certainly intended to apply to the property > only, especially because parameter attributes have not been supported > historically (in phpdoc). Applying it to both the property and the > parameter may cause issues for attributes that want to strictly validate > where they are used. > > I think the best answer to this question may be to forbid the use of > attributes on promoted properties entirely, because there is no unambiguous > interpretation for them. I also think that using attributes pushes this > "syntax sugar" to its limit, as you can easily end up with a 50 line > constructor signature that way, at least if I'm going by some of the more > involved uses of annotations... > This last proposal would kinda defeat constructor promotion and all the reasons why it was introduced in the first place. I would expect attributes to apply only to the properties on my side. If people want different or duplicate attributes on parameters, then it's normal to not be able to use constructor promotion. My 2cts, Nicolas --000000000000ca749305a45b54ca--