Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112284 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92999 invoked from network); 24 Nov 2020 23:44:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Nov 2020 23:44:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3F4831804B3 for ; Tue, 24 Nov 2020 15:09:47 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10olkn2093.outbound.protection.outlook.com [40.92.42.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 24 Nov 2020 15:09:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EVsJ4n/98WfDms/OfGVIAJUQCEURBxaMS0g0fRzji/j3jGjASErBRmyYRdLAAUNhupOXiKFQYcs+5YWv/wXc6awYcwGWkh8+FZeaXzduvbY81aY+wBOVILnyC8fmvG0iip8HKKfnz/jhzqz0IL6fSsMnfACqZJXZHUVSAKb79zcHx29ws9MkAB3wYfb23bfrClWqB+ftP1T6KZbAtG3TU1RPhSv+59XgBKNa9Gvc+lR9WnZ0iDxO90IQFzrJhtdQHa/EueG2p9NKhyDhZ5Kbi4uIJTEYmKvpZSBytFWhsyerYXs+iM8RrHk6H5EFzuSwmUfS2inW2wKl7vl4VlJqKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SqL8XJyQXCOOEJdB945GbJaATM4KkOX4OL932FcD/Cc=; b=KT8qsDzTPbxJllXXEM36OxSTXlpUOcfqEcM788REIDPmMemclNaSKcfsh19yQ3e20d/UVD3/G8cl92YoKgWyyjHSTA8vautf/jgkRisRtPFdyxoLVOaooO0hU5e+uuZBPBsJBqG48Ws5SUPw6cXYxf8QgT5cKxqCkQ7R0yjQmxAUUrMeTe9WqgwX4EmHJEQmFpbqv645YXVlCARdRBPaCGZLAil4728uT1qgjLJxT5n8n1mT9UXC8P7VQFWhDBmglcN26iS8+KGoTpjFtQzQ+IG5CdMBr6Bh/oR+zFS60r326Ip2aq/cq0k5T5L6fYnBSIlVaUrwqZMN8t94OKYg6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SqL8XJyQXCOOEJdB945GbJaATM4KkOX4OL932FcD/Cc=; b=S+gil2CLkrXv1JNM81EGQl1UFA+74gl5+O8F4a+G6ops+1HQ7EH7HntxxI6hHmVZt2Y6AmZjehAaK6dH/NzjnWQQJwp6fkNpS9pXw7WhCtUn6VW4gfbXyiElYmkyTpWSTBtrFmWYSmUBt3sGjYlCL+v4S5kqosECemIkUPDeVBwA8hnG0+ts5CygB+GeVB0qeyNe3ds9JKrQowQEmHRIoyFuJFjN3cXGc3lJuLg5qMXmTCCbUBMBpcSxV1+kAoISa2lloaaW0crI+G722BXAApedJ1B//M4tyLfo24SOqyoKOYyDnYmRdCdVnvgJATyfZ8uCIjfq5+uC3PD8t9TbJQ== Received: from MW2NAM10FT060.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::44) by MW2NAM10HT167.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e87::111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.25; Tue, 24 Nov 2020 23:09:44 +0000 Received: from BYAPR05MB5478.namprd05.prod.outlook.com (2a01:111:e400:7e87::41) by MW2NAM10FT060.mail.protection.outlook.com (2a01:111:e400:7e87::363) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.25 via Frontend Transport; Tue, 24 Nov 2020 23:09:44 +0000 Received: from BYAPR05MB5478.namprd05.prod.outlook.com ([fe80::8c94:5632:4960:d76a]) by BYAPR05MB5478.namprd05.prod.outlook.com ([fe80::8c94:5632:4960:d76a%6]) with mapi id 15.20.3611.015; Tue, 24 Nov 2020 23:09:44 +0000 To: Larry Garfield , Rowan Collins CC: php internals Thread-Topic: [PHP-DEV] List of attributes Thread-Index: AQHWlKduqAD4JLWTfUSbO6DleNAbtql92cYAgAAq64CAATgcAIAJ4ESAgBYMm8qAAZRFgIAEqHeBgAgHdACAABBagIADMPVMgAANRYCAABWhiYAA34aAgADzwYCAJZ6FFQ== Date: Tue, 24 Nov 2020 23:09:44 +0000 Message-ID: References: <258d9a8e-e73e-7b8a-5d9f-64a449def1da@gmail.com> , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:AF37EF2419C0E69055BF7773A1112C196BE06B2DCC1F694B20B28C36B4527863;UpperCasedChecksum:89F69AE6001834E4F76706A4E26373BA19BFEA63A4A4BC8735282D72BBE777D5;SizeAsReceived:7977;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [23k84xoJNJlxmn97Ft72JVK9m/Y8n95q] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: feaf4004-63af-4fec-97c6-08d890ce0809 x-ms-traffictypediagnostic: MW2NAM10HT167: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wqMTQL9XHCRtgKGTDL7jQ/L453DgEVqUj+WbUYc4q5TEeyktmIackyhSUG9wj0fB/+12vVx4PLEb3vwSL7cvgyrOEdWtYVv0dQL1flYtLZfwy0OtTDklhrVh0cTJeBaFsTvLdSaNXV4frqFmq+fEj6SUZcfvNbiQ2DBLFgZ8cmaiMFmkiRLwzeLq4NCIgF6flAH/HmisJ+RgUvExNRLg9Q== x-ms-exchange-antispam-messagedata: INf4awWk61WRnhB5SnI2Ihn9H0uWSgbau6Dct0IGnkFTNBFZGQtuZhXWIJyJKzUy+zZaFsv5mK79VjDbZ1Y0HdgjfWyuFwXWpKLTbzbgvS3FbE11PbV04BTuOMEYg1fqYZdxt/Hu5VHK5g25SkdIOw== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT060.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: feaf4004-63af-4fec-97c6-08d890ce0809 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2020 23:09:44.4444 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2NAM10HT167 Subject: Re: [PHP-DEV] List of attributes From: theodorejb@outlook.com (Theodore Brown) On Sat, Oct 31, 2020, at 5:06 AM, Rowan Tommins wrote:=0A= =0A= > > This would be an artificial limitation on attributes to patch=0A= > > over the inherent inconsistency of the grouped syntax for nested=0A= > > attributes.=0A= >=0A= > There is no artificial limitation; there is a binary choice: does=0A= > #[Foo] represent an object or a list with one item in? This is=0A= > completely new syntax, so there is nothing for it to be inconsistent=0A= > with other than itself.=0A= =0A= It is very much an artificial limitation. Developers would be prevented=0A= from declaring that an attribute must be passed a single attribute =0A= with a particular type as one of its parameters. This isn't a natural=0A= or inherent limitation of attributes, but an artificial one in order=0A= to try to make the `#[Attr1, Attr2]` grouped syntax usable with nested=0A= attributes.=0A= =0A= > I am arguing that having it represent a list with one item in is=0A= > actually *more* consistent, because when you attach attributes to a=0A= > declaration, they are always retrieved as a list.=0A= =0A= That's not necessarily the case for nested attributes. A developer=0A= may want to declare that an attribute constructor takes a single=0A= attribute with a particular type as one of its arguments. Why should=0A= PHP prevent this by only allowing a (possibly empty) list to be=0A= passed? Again, this would be an artificial limitation that reduces=0A= the flexibility and usefulness of nested attributes.=0A= =0A= On Sat, Oct 31, 2020 at 7:38 PM Larry Garfield wro= te:=0A= =0A= > Perhaps a naive question, but I'm missing the downside of:=0A= > =0A= > #[Foo(Bar(name=3D"baz"))]=0A= > =0A= > #[Attribute]=0A= > class Foo {=0A= > public function construct(public Bar $bar) {}=0A= > }=0A= > =0A= > class Bar {=0A= > public function construct(public string $name) {}=0A= > }=0A= > =0A= > Why is that not OK? Someone mentioned it means you couldn't call a=0A= > function there, but... that's not a huge problem because I can't=0A= > imagine why you would. If we really wanted to avoid that:=0A= > =0A= > #[Foo(new Bar(name=3D"baz"))]=0A= >=0A= > That would be unambiguous, if a bit ugly.=0A= =0A= As I mentioned in my first email in this thread, there was an attempt=0A= to do this back when the original `<<>>` attribute syntax was being=0A= implemented. But this approach ran into difficulties since it would=0A= require significant changes to constant expressions.=0A= =0A= Even if someone finds a reasonable way to make such a syntax *work*,=0A= it still has the downside of requiring a different syntax for top-=0A= level and nested attributes (docblock annotations allow using the=0A= same syntax for both). Moreover, re-purposing the syntax for function=0A= calls or class instantiation is likely to cause confusion, since it=0A= looks like the code is doing something other than what it actually=0A= does (and of course it would prevent ever extending constant=0A= expressions to support function calls or class instantiation).=0A= =0A= One of my main motivations for proposing the `@@` shorter attribute=0A= syntax was to avoid the complexity of grouped declarations and allow=0A= using a single consistent syntax for both top level and nested=0A= attributes. I fear that the change to the `#[]` syntax with grouping=0A= will prevent PHP from getting a flexible and intuitive nested=0A= attribute implementation, and devs will be forced to stick with=0A= docblock annotations for these use cases.=0A= =0A= Kind regards, =0A= Theodore=0A=