Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112106 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34881 invoked from network); 23 Oct 2020 16:34:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Oct 2020 16:34:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 73D8A1804C6 for ; Fri, 23 Oct 2020 08:52:27 -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=-0.7 required=5.0 tests=BAYES_05,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 NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2037.outbound.protection.outlook.com [40.92.20.37]) (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 ; Fri, 23 Oct 2020 08:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J3gMkTdWgcDZT8z5NPz71z72q77futbJnVpCZhpLacjLbc7lKPWmWZeFEhp3vROFo++m4L+0nqgC1LqxWfKMdDd8tSYEJCkRGrF0vVNDZyXJ2LDCWz9rzsvsLgZNCbR5ZtFu/+SGFuX6ctpXyLpiz6HsskxCMAnaP+uNerRB5o4dkyB1Dw/z1WS8OnbXGsL0SF2zaboaZn9I2mrijFHa9uhUt5gjsiHTa2a5byGTVAxw5rZbIAdUhnAtW3eJlNUMT6lotwcQE607/g8BGtxKGFU7elTkGRhlF7Hlx0aysINLzK4Rc3IpffRW2CeiezdGWqMKWcaqC4YvvKwJ8xDvOw== 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=gPc9Ldk5gYkQshwlI+0UyxvkpEiZAgKQmNjGzqvsLUU=; b=Avq5OQTNun2H8c/4NvSQt8u74I59xHc8NQY5SabbXfH5Ah16mro5ITtOoYmioM145ow+Zn8wnL/R4kpL6Dh3CqGj1gP6H5cvSjsat8tVUWjuLwSPngX/7fKNLldiItm+W40Xh1lb1jJUs5OcDs5e+8BfNdBjLl1LbRCAVQErqITyAmPn49CYP3CD9Z2yHH9euvViDNK3ORrHOrscMc8pMhAtySxGMOYOfCbr2TpvT2xfoztLNvbNLKDk+AHunhawGFKmIoRjEW2UsQNWpAAHARoRWPqtFlQZjcm9PbU7Vnx2GiItd+nBJCkg5Tw9a0HEnxlPyvtwtVBzlwhk/YSJMA== 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=gPc9Ldk5gYkQshwlI+0UyxvkpEiZAgKQmNjGzqvsLUU=; b=foH3yOZHe1mkX4rxy6TLSYAmp6319LIlF1Mt7lRGfrE/vWwNOO3CMgAcdSKjPzFY8igQI+Xt7fplg5NeQuF6+o1K6wP1Gdz3rZ8U9mYvsXrDznPZJ5bfDu0Atix8aHOkhZ5cZrA0XMViajleBDHBLZm0r47EtwPw99jp07mBb7WLYsuNEDBD37ww4m2jKCozgEZwGfbJC7Ps67Je4fvaprW176YuPRLdBusb46GggKEEgvM9BPeaqVMwr4lGAvavZOVafiMhVEiuexMc9DLYZLp6Yw7rtwVLoWMHYKZNTroZYNOTh78rCQMddubx8nFfBMYvZElf2atos517cZnUGg== Received: from CO1NAM11FT046.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::4f) by CO1NAM11HT085.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Fri, 23 Oct 2020 15:52:25 +0000 Received: from BYAPR05MB5478.namprd05.prod.outlook.com (10.13.174.60) by CO1NAM11FT046.mail.protection.outlook.com (10.13.174.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Fri, 23 Oct 2020 15:52:25 +0000 Received: from BYAPR05MB5478.namprd05.prod.outlook.com ([fe80::1520:24a9:8177:7990]) by BYAPR05MB5478.namprd05.prod.outlook.com ([fe80::1520:24a9:8177:7990%5]) with mapi id 15.20.3499.009; Fri, 23 Oct 2020 15:52:24 +0000 To: Rowan Tommins , PHP Internals List Thread-Topic: [PHP-DEV] List of attributes Thread-Index: AQHWlKduqAD4JLWTfUSbO6DleNAbtql92cYAgAAq64CAATgcAIAJ4ESAgBYMm8qAAZRFgIAEqHeB Date: Fri, 23 Oct 2020 15:52:24 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:27D37348E26B5684500D3007C07D0E6FAF9B32CCDB5A82B68F13CC0C62D1C8E3;UpperCasedChecksum:EB8ACB053255869C7266E4B4B0B10E33FBC09744AF783D077B3EC077B7D7AC1A;SizeAsReceived:7351;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [2L/Yy2PVRhlT+Jj9l2n+C0pK41qVzJRp] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: e8fd0ee1-86f4-4510-e0fb-08d8776ba2c9 x-ms-traffictypediagnostic: CO1NAM11HT085: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +2l1iBC7edsAggzEAV5tnjR7LODSVIMmmdItTbgtkaq27U/hZ74biulJ0zrZbXPqm60WvyWFFHjey9zgft4MMc8KF5ZGinsR1kiDjKX6rD4Nj7UftBOm9SliOyea58ornyy4NZlLUEDaZf3uUA3S5A2CchDIGH8mKrgxpxICIYaqhIReMELQ3sfIYjnliv+x6poG5McKIuyrFfknrziAcw== x-ms-exchange-antispam-messagedata: /Bl+wW506zpaGxUeRSq6zfGf0TIdIPBjPUiaLcPkFV5n+jVZdOW/rj8vqu+GFol5LodI3l045WP9+74G1Z5P2nq7YWRZVlypY4ls5f1oXElkQGll+b32OszHTNNxo85kNcaSROAn9l7WqU1bIHDX2g== 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: CO1NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: e8fd0ee1-86f4-4510-e0fb-08d8776ba2c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Oct 2020 15:52:24.7871 (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: CO1NAM11HT085 Subject: Re: [PHP-DEV] List of attributes From: theodorejb@outlook.com (Theodore Brown) On Tue, Oct 20, 2020 at 10:13 AM Rowan Tommins wr= ote:=0A= =0A= > On Mon, 19 Oct 2020 at 16:17, Theodore Brown wro= te:=0A= > =0A= > >=0A= > > In theory nested attributes could be supported in the same way with=0A= > > the `#[]` syntax, but it's more verbose and I think less intuitive=0A= > > (e.g. people may try to use the grouped syntax in this context, but=0A= > > it wouldn't work). Also the combination of brackets delineating both=0A= > > arrays and attributes reduces readability:=0A= > >=0A= > > #[Assert\All([=0A= > > #[Assert\Email],=0A= > > #[Assert\NotBlank],=0A= > > #[Assert\Length(max: 100)]=0A= > > ])]=0A= > >=0A= > =0A= > I think you're presupposing how a feature would work that hasn't=0A= > even been specced out yet. On the face of it, it would seem logical=0A= > and achievable for the above to be equivalent to this:=0A= > =0A= > #[Assert\All(=0A= > #[=0A= > Assert\Email,=0A= > Assert\NotBlank,=0A= > Assert\Length(max: 100)=0A= > ]=0A= > )]=0A= > =0A= > i.e. for a list of grouped attributes in nested context to be=0A= > equivalent to an array of nested attributes.=0A= =0A= Hi Rowan,=0A= =0A= The problem with this is that it results in inconsistent semantics,=0A= where the number of items in an attribute group results in a=0A= different type of value being passed. I.e. if you remove two of the=0A= three attributes from the list, suddenly the code will break since=0A= the `Assert\All` attribute is no longer being passed an array.=0A= =0A= // error when Assert\All is instantiated since it's no longer being =0A= // passed an array of attributes:=0A= =0A= #[Assert\All(=0A= #[=0A= Assert\Email,=0A= ]=0A= )]=0A= =0A= So when removing nested attributes from a list such that there's only=0A= one left in the list, you'd have to remember to additionally wrap the=0A= attribute group in array brackets:=0A= =0A= #[Assert\All(=0A= [#[=0A= Assert\Email,=0A= ]]=0A= )]=0A= =0A= And of course when you want to add additional attributes to a group=0A= that originally had only one attribute, you'd have to remember to=0A= remove the extra array brackets.=0A= =0A= Generally speaking, having the number of items in a list change the=0A= type of the list is a recipe for confusion and unexpected errors. So=0A= I think the only sane approach is to ban using the grouped syntax in=0A= combination with nested attributes.=0A= =0A= Unfortunately, no one thought through these issues when proposing to=0A= change the shorter attribute syntax away from @@ and add the grouped=0A= syntax, and now it seems like we're stuck with a syntax that is =0A= unnecessarily complex and confusing to use for nested attributes.=0A= =0A= > Unless nested attributes were limited to being direct arguments to=0A= > another attribute, the *semantics* of nested attributes inside=0A= > arrays would have to be defined anyway (e.g. how they would look in=0A= > reflection, whether they would be recursively instantiated by=0A= > newInstance(), etc).=0A= =0A= Yes, the exact semantics of nested attributes need to be defined, but=0A= this is a completely separate topic from the grouped syntax issue=0A= described above.=0A= =0A= As a user I would expect nested attributes to be reflected the same=0A= as any other attribute (i.e. as a `ReflectionAttribute` instance).=0A= Calling `getArguments` on a parent attribute would return an array=0A= with `ReflectionAttribute` objects for any nested attribute passed=0A= as a direct argument or array value.=0A= =0A= On first thought I think it makes sense to recursively instantiate=0A= nested attributes when calling `newInstance` on a parent attribute.=0A= This would allow attribute class constructors to specify the type=0A= for each attribute argument. But again, this is a separate discussion=0A= from the issue of nested attribute syntax.=0A= =0A= Kind regards, =0A= Theodore=0A=