Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120318 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12264 invoked from network); 16 May 2023 16:55:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 May 2023 16:55:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E8F1C1804D0 for ; Tue, 16 May 2023 09:55:26 -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.4 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 16 May 2023 09:55:26 -0700 (PDT) Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-965d2749e2eso2190833466b.1 for ; Tue, 16 May 2023 09:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684256125; x=1686848125; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=viLoSSmde5zGTAHLazjfhihQidqmfnSAJEczZO5o5Pc=; b=EoC5oqYZGUedQII/r4Y2mnsfI5K41qNEigvhxfnLztNWpBykQfl23uqSziCtsNOm14 YvG49p0vDm6xw+aqlu62VnU/NtoSPn3uVYh76USIeDcYXwc9MiZSt7p+0KrSWA/Q/bd2 AMufbC3m678SGxk/SteJ4AM4bYe62HaEfCJVd7d7BzWa0odyP5XWbMFOhi4ATiTO6ZkI YRNzHbpyJySOqc+TVHVrFYvHUN7mXQdUSKN3s36rqv4w47xAjYkt3ZrTHLTmUcNaGrzF R8gV0t7HO3R7wKaBbI5mkMGwqlQDXLrZqA+Y/7Tujcqt5CTKGOoPi+caQeoCMs75JQbz CwFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684256125; x=1686848125; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=viLoSSmde5zGTAHLazjfhihQidqmfnSAJEczZO5o5Pc=; b=XD8839ou1yUM2h4MWgA8kjNe+LSxVmdly9vLaWZr3HRLpY6jXHYq0OGIQNubx/rkqA SgO3+P8yJCRRhhJiBFivg8oA4AU0qkJx/c1FNvErMl2AapWLZ+QvwIqvyhF1rkFXwpE7 uILKsEhDq/hNUJEjGyYvNUX1hc58+zH1Ke0vdEG2aOpbQo9Sn7IuYufBYT4BIvOinykl WbSAjl65PEFoEMcunC/mN6zmHItwAm/XVdtqy3oMOzCtKs5C7zeFmseiy+XhyZgdGkm8 5LVC3UNvAKIM7HYUVb5QJLo3DcJs1W/NH6F1kvzqxZd3PWyJrXiLp5NupIDWdwpV072f n8aA== X-Gm-Message-State: AC+VfDy+9+fE3tfhqgL8H8XI9YoYQ6R9p/niBsYUE7a12yEM3HocvUl5 2bRpya94k8DKu2TSzNTkSnmlqIO2+0vXSJLeGOPJZ0AKAss= X-Google-Smtp-Source: ACHHUZ7PYkz/V1md7EI+WBGmLbIZQzeQmx2LRr2PLbV8nRvERPFdgXrW3J1FtG/T5cLi4570aNuDknzKE2bI0TVTk94= X-Received: by 2002:a17:906:6a16:b0:966:eb8:2f12 with SMTP id qw22-20020a1709066a1600b009660eb82f12mr36274376ejc.11.1684256124761; Tue, 16 May 2023 09:55:24 -0700 (PDT) MIME-Version: 1.0 References: <436378BB-FDFA-43BD-A633-C030C347E683@gmail.com> <359D9C64-52A5-4BF5-91B5-72F7CE116F78@gmail.com> <8D0D9132-7CBB-4EC2-9AB8-0CB1C502A7B3@gmail.com> In-Reply-To: <8D0D9132-7CBB-4EC2-9AB8-0CB1C502A7B3@gmail.com> Date: Tue, 16 May 2023 18:54:58 +0200 Message-ID: To: PHP Developers Mailing List Content-Type: multipart/alternative; boundary="00000000000006fac005fbd27026" Subject: Re: [PHP-DEV] [RFC] [Discussion] nameof From: flexjoly@gmail.com (Lydia de Jongh) --00000000000006fac005fbd27026 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Op ma 15 mei 2023 om 20:06 schreef Rowan Tommins : > > On 15 May 2023 14:07:31 BST, Lydia de Jongh wrote: > >> ... > >> #[SomeAttribute(callback: nameof(\Acme\bar(...))] > >> ... > > > >This callback to nameof()..... is really terrible =F0=9F=98=A3=F0=9F=98= =A3 > > Just to be clear, the "callback:" in that example is existing syntax for named parameters, not part of the nameof() syntax. A positional parameter would just look like this: > > #[SomeAttribute(nameof(\Acme\bar(...))] > > That's the same number of characters as this: > > #[SomeAttribute(\Acme\bar(...)::nameof] > oops =F0=9F=A4=AD=F0=9F=98=B3 tx! So because nameof() is not a real function, it works as parameter in attributes.... nice! > The main difference is the the function-ish syntax makes it a bit clearer what you're asking for the name of, because the whole thing is in parentheses. There might even be cases where the function-ish syntax needs additional parentheses anyway, like are needed in (new Something)->doSomething() Sure. I just think we need both nameof() and ::nameof Just like we have get_class() and ::class..... > > Changing "nameof" to "function", "method", etc depending on type doesn't really add anything, since the output is always a string anyway, not some type-specific thing. True.... I only suggested that because '::class' exists and not something like: ::nameof or ::pathof. And thought that maybe the choice for ::class was deliberately Op ma 15 mei 2023 om 19:45 schreef Robert Landers : > > There are no magic constants in this RFC. May I ask why you do not add a magic constant as part of your RFC? If I would make an RFC for it, it would be almost a duplicate of yours..... And I cannot contribute to the codebase, as I do not know C or in whatever language php is written :-( But I could help with documenting and writing for the RFC. Quote from RFC: "When getting the name of constants and functions, the name will NOT be the full name, but the lexical name. This means that if the name is use'd, it will be that name. However, if the full name is used in the nameof(), the full name is returned. It's probably easiest to show this with an example: <...> echo nameof(MY_CONST); // MY_CONST echo nameof(\Name\MY_CONST); // \Name\MY_CONST " This looks confusing to me. As it is best practice to import with use and without using fully qualified names inside your code. Maybe consider a second bool parameter to full name or not. Or have a second 'function' like: fullnameof() Looking again at your RFC.... I just realized.... it is about variables, properties, functions, methods etc. not about classes... =F0=9F=A4=94 (ploi= nk) In that case you are right that you mostly want the unqualified name. Most of them do not even have a different fully qualified name. Only items that are namespace aware have that. But local variables and items inside a class, they have just one name. Or am I mistaken here? So maybe it does not help to talk about fully qualified or not. Greetz, Lydia --00000000000006fac005fbd27026--