Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112016 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69479 invoked from network); 6 Oct 2020 16:02:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Oct 2020 16:02:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3F8881804B5 for ; Tue, 6 Oct 2020 08:15:31 -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=1.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL 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 ; Tue, 6 Oct 2020 08:15:30 -0700 (PDT) Received: by mail-lf1-f52.google.com with SMTP id b22so15425065lfs.13 for ; Tue, 06 Oct 2020 08:15:30 -0700 (PDT) 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=VcS4VHsJaKNXHguvY/96IvVqB6/7tqSHCiflGlBsWs4=; b=KQfs1F1JZv0dN1nshh/tj9QCHUn2LXG/98OsZfFIdl9GDxdOfbWJyD/4rK3faYxds3 3l30o94bwiu/kmJI7Z1ygnKM0n16nfPclmZIZMjjXKPF416ra/ELEyM2poKG3G2t/t8g F6uDHFpC8RJE1plfusDtbRZMwmKV5wbGNF62W8CNDHBY7MdapOfGQYtj49u8Lc2scF2L KwOXxpkIMnAzK+OmMBr4s/6mOlOOSHKBF10qVyt9ksN28z42/3PrDbC4jGJimrheNSNc q7npx273yKJXu50jUW2jjI3zMPZLV02VerTuNozMGiEpPq1kg5OXUK/YVlfceR8Kb+ZG miWA== X-Gm-Message-State: AOAM533DpEc8WjBJYZDgfqzkFYsN5Ys9tZ6I8irBbz+shyrNtMbnY6ya ZGAiEwrMrvKrne+tieMlzPyY2dfhdNL+FKJiBh7e+g== X-Google-Smtp-Source: ABdhPJxeiEbmWjvfkfLhupsz0cVm3UfmqYmVStg3fReWa31w8n6dwsPS37w8NysEN0Rvl5uFEFD3xpYXAYIrFcafpWk= X-Received: by 2002:a19:c112:: with SMTP id r18mr659289lff.208.1601997326158; Tue, 06 Oct 2020 08:15:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 6 Oct 2020 10:15:15 -0500 Message-ID: To: Nikita Popov Cc: PHP internals , Benjamin Eberlei Content-Type: multipart/alternative; boundary="0000000000008eaf8605b1021166" Subject: Re: [PHP-DEV] Attributes and constructor property promotion From: pollita@php.net (Sara Golemon) --0000000000008eaf8605b1021166 Content-Type: text/plain; charset="UTF-8" On Mon, Sep 28, 2020 at 5:36 AM Nikita Popov wrote: > When the constructor property promotion landed, the question of how it > interacts with attributes on promoted properties did not get fully > resolved. See https://wiki.php.net/rfc/constructor_promotion#attributes > for > what the issue is. > > The behavior that landed was to apply the attribute is applied to both the > parameter and the property. However, this was with the understanding that > we may have to adjust the behavior later, in particular depending on how > the whole "attribute target validation" turns out. The way it is now, using > a property-only attribute on a promoted parameter may result in spurious > validation errors. > > I wanted to bring up this topic now to make sure it's not forgotten... I > still don't really know what the best behavior here is. > > My opinion on constructor property promotion (CPP) is that it's something for small value object classes and should probably be regarded as code-smell on larger classes. At the same time, annotations belong with more complex objects and not so much with small "struct-like" classes. Given that position, I think we should err towards strictness in how attributes are applied to CPP declarations. That is, we should require them to be meaningfully applicable to both arguments and properties in order to be used in a CPP context. If that's a problem for the consumer, then they should avoid use of CPP. -Sara --0000000000008eaf8605b1021166--