Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109876 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66414 invoked from network); 28 Apr 2020 16:16:35 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Apr 2020 16:16:35 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0D0F91804C4 for ; Tue, 28 Apr 2020 07:49:46 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 07:49:45 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id j14so17127340lfg.9 for ; Tue, 28 Apr 2020 07:49:45 -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; bh=5n6iBeGFK89vvAxsdyxR9x3//PkHHaOebXGgXGCG1vI=; b=qrOsyKQrAi+BnhpbTIev6Xh6UgqomVN4uV2UIWB+vHG9amv/1nWZazARw/cVQ3O3Ps LtzlkZUcGGpVeKhZBXxlK6Ls+apFJ37tCvHotfN0p98JaGP334gEhkm3Q22/ecx41fuO FkDiE0d9QOSjLKBF5vuGxynBqVxncq+SJ3+wYHP56oS0Zl2cuZCsIl+0aVrJg6seNy78 irtw9fYPmIcZd29bQr9wNynbKJH6zV66GnHOJj5mjDf84wfYGUveclinKZApwBCBgl0q RFUNRHG+MaEaK6DHEHOhrlIBSH+AxjsMRgZPLFdC7XdYrgUgqaI1oJwPb3JkLoTo7NY0 1mfw== 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; bh=5n6iBeGFK89vvAxsdyxR9x3//PkHHaOebXGgXGCG1vI=; b=Eq2wZfRq6w/nDLltEycgYJvFOtr43oLG2jS4XbGFyE2LAOe0k0JJt+xA4Bh1G7Qn55 akxq8CmxDCf/D0T4DR/qOuOSLmMIU/XIx/7uxjQB9HetAvtRj7dpdkAgQ86u7LdjKgud Fxq26dbPreHaBv1wzPkDOKYLwwKYoEVFpyiBtsXmMVgz75Q2MgKbMh5YOoTqFYrbn2YI YR5lMumIqxee0Ywyhr0W3Qx+gRLQJkQTjx0vcuRWlIHx7OJyJf5Y6zV15CEJFGELEak4 bRwZX8B2WRvmDwFulVPb+NSsCg2fCL4eJuu/Ok3z3EWG6vQy0+LoWtIowrBJABxd5kfH vzyw== X-Gm-Message-State: AGi0PuZVmaK0zudaMs7N2sRu0r+6UnSJKgkl5Zi65YTQhzcG2JG/9M7I 1VkIJZn7VBvLMtI49M1gukVIWA9+odBnxOlbZer/9D2ZJj0+/g== X-Google-Smtp-Source: APiQypLhHEXlsiOmoms3Hv/DrHrAVyGwv5lsTeP5PqkndET/BpNLWDje15C0AITL4wFhxwT1qlADbi0MA/+8CtVQVHU= X-Received: by 2002:a05:6512:54c:: with SMTP id h12mr18949290lfl.120.1588085382901; Tue, 28 Apr 2020 07:49:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 28 Apr 2020 16:49:26 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000001ef5b305a45af16d" Subject: Re: [RFC] Constructor Property Promotion From: nikita.ppv@gmail.com (Nikita Popov) --0000000000001ef5b305a45af16d 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... Does anyone have thoughts on this? Regards, Nikita --0000000000001ef5b305a45af16d--