Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112156 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5062 invoked from network); 31 Oct 2020 10:46:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Oct 2020 10:46:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0FB1D1804B5 for ; Sat, 31 Oct 2020 03:06:15 -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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 ; Sat, 31 Oct 2020 03:06:14 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id p22so4919720wmg.3 for ; Sat, 31 Oct 2020 03:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=a7h4sAMGRVEFCUjF+cu6tJS6lYRicoiQ+hRvUzLdvl0=; b=PHXz8/ieX1VZnKMwfMFKGnL3l+waAuscTv28tDKb9JGILcl18TfLMJY6iXwEZlWHEN tZSt1KK4egCo5577V9S8kRoh7nAqwBj/lwlIylDlpZeHwRc3EVRa91tq2g5mNW2L0Ip6 6gZ2eD9WY5c3efTrVqjP3VLcYLmmVZpQ2MkG+IAitmU+ooz5zC/o9j8MUxWzK8s0/W/1 PsDbauEmJ6L9211oViF17A1GAdDKbgB44Q/whd2FoJ/aAMXOoZFrWurkeN3vWQ9Vzohy NHPRprAIXSUTUUlzj5F+I190zFQZZaQpskmuMXizpML8y42kx284oh254ZQ+4Rn6tjsV HwRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=a7h4sAMGRVEFCUjF+cu6tJS6lYRicoiQ+hRvUzLdvl0=; b=YwkdunU28kTQjF90PYoZAs3mq2i1ELItYtWx0J7ny+3p+HoItMdAq0hiNOV1/zdN6f O8WsGkWjH6tCSklYsoNxk3v54TJYtgL4vuZYa/VUY1et8frPhcC+q4Se4UvIuzLeplxl TU4LphJtbwDZX7L9oevwcJ21gl5GGFB0KC72XxlcaC0hrz4sBvBZyAcxUADddhhHWHkL /jU9rKVxZxfEorBiAaNv6NdCfEcJYXG2HERXXv5LWB1tADj9arRIawMmziPgpaJHTJD1 Z71VNiLxClM103vVqixe0bmB1TcZBiRZBxHPseBnaQa3jbc1A5DWOeKsOOyrCtIqccDq GmQQ== X-Gm-Message-State: AOAM530yCsQ9x4yo1i/JtcGeImL+Mqs6xy6ONacJbIO+i1d2W2DGUsVg L9Br5WnbCrOIOlUjio/S5sWHUjYHb3g= X-Google-Smtp-Source: ABdhPJyCekcR7Iv9h3iiCUIOoAYxcLzgMlCHCuLoSWT2fVG8d8zl/PIpiHVUbowIX1hSdGwXPkm7SQ== X-Received: by 2002:a1c:c30a:: with SMTP id t10mr7161423wmf.183.1604138771388; Sat, 31 Oct 2020 03:06:11 -0700 (PDT) Received: from [192.168.0.12] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.gmail.com with ESMTPSA id v14sm14541188wrq.46.2020.10.31.03.06.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 31 Oct 2020 03:06:10 -0700 (PDT) Date: Sat, 31 Oct 2020 10:06:07 +0000 User-Agent: K-9 Mail for Android In-Reply-To: References: ,<258d9a8e-e73e-7b8a-5d9f-64a449def1da@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: PHP Internals List Message-ID: Subject: Re: [PHP-DEV] List of attributes From: rowan.collins@gmail.com (Rowan Tommins) On 30 October 2020 21:54:10 GMT+00:00, Theodore Brown wrote: >The fundamental advantage of using an attribute here instead of an >associative array is that it enables IDE autocompletion, and allows >static analyzers to catch any mistakes in the parameter names/types >before the code runs in production=2E Yes, in general being able to declare structures rather than associative a= rrays is useful=2E Note though that that's not unique to attributes, nor ar= e third party static analysers limited by the native facilities of the lang= uage=2E >> So there's nothing really "attribute-y" about the CustomError class, > >What do you mean by "attribute-y"?=20 I mean that unlike the Symfony examples, CustomError is not something that= you'd use as an attribute on its own, actually attached to a declaration; = it's just a container for some data=2E=20 >The `CustomError` class would be a >normal attribute, and as such when calling `getArguments()` on the >`Limit` ReflectionAttribute it would return a ReflectionAttribute for >`CustomError`, which would allow its arguments to be inspected without >loading the class=2E I don't understand what the advantage of that would be in this case=2E If = you "inspect" the arguments without running the constructor or even loading= the class definition, isn't that just the same as having an associative ar= ray? >> and any "static object declaration" syntax would do, e=2Eg=2E >>=20 >> #[Limit( >> min: 10, >> max: 100, >> error: CustomError{message=3D"=2E=2E=2E", notify=3Dtrue, >withTrace=3Dfalse} >> )] > >It's not clear what exactly you're proposing here, or how it would >work=2E I don't want to get bogged down in the details, it was just a quick exampl= e; the point I was trying to make was that if CustomError is just a data ob= ject, then the requirement is some syntax for creating data objects in scop= es where that's not currently allowed=2E That includes in the arguments to = attributes, but also includes, for instance, constants, property defaults, = and parameter defaults=2E=20 >There is no general problem of not being able to specify that a >parameter takes a single object with a particular type=2E=20 No, but there's a general problem of not being able to specify that a para= meter takes a list of a certain type, and this would be one of many, many p= laces where that is a minor nuisance largely solved by third party static a= nalysis tools=2E > This would be >an artificial limitation on attributes to patch over the inherent >inconsistency of the grouped syntax for nested attributes=2E There is no artificial limitation; there is a binary choice: does #[Foo] r= epresent an object or a list with one item in? This is completely new synta= x, so there is nothing for it to be inconsistent with other than itself=2E I am arguing that having it represent a list with one item in is actually = *more* consistent, because when you attach attributes to a declaration, the= y are always retrieved as a list=2E Regards, --=20 Rowan Tommins [IMSoP]