Re: List of attributes
| From: | Rowan Tommins | Date: | Tue, 20 Oct 2020 15:13:55 +0000 |
| Subject: | Re: List of attributes | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112080@lists.php.net to get a copy of this message | ||
On Mon, 19 Oct 2020 at 16:17, Theodore Brown <theodorejb@outlook.com> wrote:
>
> In theory nested attributes could be supported in the same way with
> the
#[] syntax, but it's more verbose and I think less
> intuitive
> (e.g. people may try to use the grouped syntax in this context, but
> it wouldn't work). Also the combination of brackets delineating both
> arrays and attributes reduces readability:
>
> #[Assert\All([
> #[Assert\Email],
> #[Assert\NotBlank],
> #[Assert\Length(max: 100)]
> ])]
>
I think you're presupposing how a feature would work that hasn't even been
specced out yet. On the face of it, it would seem logical and achievable
for the above to be equivalent to this:
#[Assert\All(
#[
Assert\Email,
Assert\NotBlank,
Assert\Length(max: 100)
]
)]
i.e. for a list of grouped attributes in nested context to be equivalent to
an array of nested attributes.
Unless nested attributes were limited to being direct arguments to another
attribute, the *semantics* of nested attributes inside arrays would have to
be defined anyway (e.g. how they would look in reflection, whether they
would be recursively instantiated by newInstance(), etc).
Regards,
--
Rowan Tommins
[IMSoP]