Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108924 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72110 invoked from network); 9 Mar 2020 22:10:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Mar 2020 22:10:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8CD801804D3 for ; Mon, 9 Mar 2020 13:30:56 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE 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-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 ; Mon, 9 Mar 2020 13:30:56 -0700 (PDT) Received: by mail-wm1-f50.google.com with SMTP id p9so968544wmc.2 for ; Mon, 09 Mar 2020 13:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DAvtS48KE2L4eJ3gl313hguLCK6kIoQDzzZ5L0zgVas=; b=TVx8ww6lqzsO2j1WJpdgyKNXXw5o5fwkODNNKLAbzNH0la9habnrZ75NC0zShKdx8y VJbk0AMmrLIFzpDakM26J6NCEWkW/87FP8l/oaSxUwHT5TeuWrNuyBv6zcgboWL6OgaO QzjhvvaEaHgMqxsl2YXjBDcHiUkNj5LDqCswjA5EnHlK06ZtJqcAnQtJajW1J7h58BHA K+v9xoA/xppEcCce28iV86scW05JearpMH5Yh0SzfUM7aanCnZS7NWzq5nN+lYlzCaYn W48qYo8vLFgKuIeuaqBskXSuT2zkUFUxBI0MNF09ZAbhArufv98XssXneqFEZAYAjZuZ tcTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DAvtS48KE2L4eJ3gl313hguLCK6kIoQDzzZ5L0zgVas=; b=OHA2C6a6pJdCLld+nHPqkhuWSHYEgyJ+MwhgPz2IiTX7LvUyOQDFgwzK1UlXaIlEN0 7AtNZtAxtvCu52IkojffO1GuhDnkIFVQmqTBJDQauCLDE+Ym4Viheqi3/Wzc/ntEkQQM qrSYGdwJnLb1DfKJ6bta073OstHU1Up5ACNNwzqvyzTIdSN0DhqNCH/CanLetFXXbq8B Z+vJl+1vhMSBR+m0aJ03hdhVMbqMSy/HMA3ziTKbZU0/m6LndQdAOgl/zV8mFoXzt3ym 7p9RILqaHZbUro9E3AseZ8X6l0PmDNpE11O0dntvJxEKepUXM1/rYE4LD4DRVmbYr0kj HPCA== X-Gm-Message-State: ANhLgQ2CbCXbIzsBloIXmZbTEZKkrMH1qxc6lpvyyLrfBeaph5YrgavW f4u/WA/Iy3dUDDtvptxdS5w+6W+KTSHw9uWQLKD6Dg== X-Google-Smtp-Source: ADFU+vsbukFy6ed6Zu7Lh1GzjS9wvLTd5vmp4eIctJZNPZkM8M0Uei/DtPdgmuskjIfdPhnzW3z3qe2q07lwGL6Oh3s= X-Received: by 2002:a05:600c:290:: with SMTP id 16mr334996wmk.64.1583785851177; Mon, 09 Mar 2020 13:30:51 -0700 (PDT) MIME-Version: 1.0 References: <5e6696ab.1c69fb81.eb10c.68c2SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: Date: Mon, 9 Mar 2020 21:30:40 +0100 Message-ID: To: David Rodrigues Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000000f662605a071e16f" Subject: Re: [PHP-DEV] Re: [RFC] Attributes v2 From: kontakt@beberlei.de (Benjamin Eberlei) --0000000000000f662605a071e16f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 9, 2020 at 8:30 PM David Rodrigues wrote: > As I am not a good expert on parser (not to say that I don't do anything)= , > could you tell me if I can write a note like that? > > <<[space]Annotation()[space]>> > << MyAnnotation(1, 2, 3) >> > > It's just because I think the code is more "breathable". Until the PSR > staff decides how best to write. > Yes, you can add as many spaces as you want between << Attr >> On your other question: It is named Attributes in C#, C++, Rust and Hack, so this name is not something novell. The naming discussion is a coin flip issue in my opinion. You can't really argue to name it Annotations, just because Doctrine uses it this way, because historically it would have been docblock "tags" how php-doc named them. > > > Atenciosamente, > David Rodrigues > > > Em seg., 9 de mar. de 2020 =C3=A0s 16:19, Andrea Faulds escr= eveu: > > > Benjamin Eberlei wrote: > > > I want to resurrect Dmitrys Attributes RFC that was rejected for 7.1 = in > > > 2016 with a few changes, incorporating feedback from the mailing list > > back > > > then and from talking to previous no voters. > > > > > > The RFC is at https://wiki.php.net/rfc/attributes_v2 > > > > Hi, > > > > I have concerns about these two statements in the RFC: > > > > > The name of an attribute is resolved against the currently active > > namespace import scope during compilation. The resolved class names are > > then autoloaded to make sure they exist. > > > > > Consistent with PHP expressions in general, no validation is > > performed if the provided attribute arguments are fullfilling the > > contract of the attribute class constructor. This would happen only whe= n > > accessing attributes as objects in the Reflection API (below). > > > > These two details are inconsistent with eachother: use of an annotation > > triggers an autoload, yet we aren't using the class that is autoloaded > > to validate it? This seems quite wasteful: if we have loaded the class, > > we might as well use it to check the arguments are correct. Also, why > > are we privileging the class existing over the arguments to the class > > being correct? If the arguments can be validated at Reflection time, > > surely the autoloading can be done then too? Both types of coding > > mistake are important. > > > > It also seems inconsistent with existing PHP behaviour, I think normall= y > > mentioning a class either triggers an immediate autoload and actual > > execution/validation (`new`) or it doesn't (a type declaration). This > > proposal is a strange half-way house. > > > > Is this being done to avoid paying the cost of creating the object at > > compilation time? Because I think triggering the autoload is going to b= e > > expensive anyway, possibly moreso. > > > > On a different note, the wording here is syntactically ambiguous. It ca= n > > be read as both "if the provided attribute arguments are fullfilling th= e > > contract [=E2=80=A6], then no validation is performed" and "no validati= on is > > performed as to whether the provided attribute arguments are fullfillin= g > > the contract". I read it as the former the first time, which confused m= e > > for a moment. > > > > Another thing: > > > > > Thanks to class name resolving, IDEs or static analysis tools can > > perform this validation for the developer. > > > > Is this referencing the autoloading behaviour? I don't see why that > > would be required. (You could also be referring to the fact you use > > classes, which IDEs can look for, instead of arbitrary string > > attributes, which IDEs can not, which does make sense.) > > > > Thanks, > > Andrea > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --0000000000000f662605a071e16f--