Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108919 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 51548 invoked from network); 9 Mar 2020 21:08:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Mar 2020 21:08:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0FE291804D0 for ; Mon, 9 Mar 2020 12:29:37 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, MALFORMED_FREEMAIL,MISSING_HEADERS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS 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-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 12:29:36 -0700 (PDT) Received: by mail-oi1-f174.google.com with SMTP id k21so4455209oij.5 for ; Mon, 09 Mar 2020 12:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=45it76mqQ7wPJuCdnw1U39Q/D6rvrizTNg+LDUSy+tw=; b=oSJJBqyt/Tcxpym3k6kW1YnK1u07QjGXYwsfwZWQZF39DHyc7DipqSqEoB0r6G7FRP JBSg6YZtbB1X1WDvFXSyyLOgj/R9oZqdsk85P5DFRvxWbxY3IzvhxD59tUF/DKMuiM2p 3k4pg0Wgh6FhdvT+u15/LRhq4QJBgJTHrrVZP+gBr0pEMowWT/T3wja/roGpZEw94SRy QkKtDzcQzBhKIpWEjQLmkxJmJa/YEv7ZP/v3Bsdnz3O9y/fKfuttSBLgtTwDVMD2giaS +Wl6lD9VFo474YWHAdFD1GGPmKODDL759TO0kJ8/xDfr3K4dDtxte5gAhtFpW1fBZbk3 AgNg== 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:cc; bh=45it76mqQ7wPJuCdnw1U39Q/D6rvrizTNg+LDUSy+tw=; b=D6kZgC/aNuW8ukMbtobkc3vGvT7vWK9RdIutgJmuMJ8cKPby0wBnfUfwplOBML7KaQ 8CNcDLLKrmXsn3FoGLJwFZ2hVGROTCOswt6+Z2xKmdcXE/rWSm1Dt9b9zRDN+q7hRdTY q0zGaokZICf0rL3DePLTpx9hH63MmFSm7xtgjBQ4LZzgxd7nP9+2MGPYxSi4ClJeM0ng kwaonP82IboAFvvmmW153eEtf0crAZHWIzIqR5B8NELzSa4bYZLMy4EGtszC4rpf87w7 tgC2q1tLkhulmiygD3OGGiGglEDHzc7mpfjc2FMTerPz4dRuNK5SIDDfZnt+gAh2KF+m IKkg== X-Gm-Message-State: ANhLgQ3HUkawX6w0n7CzVtFXZrOap1t2GtWm6B43PcvqdpswWe+D3Dze sKk8t8A5QkjCc08B/rVerDHT+6Y3Ms17Yu+W5CELdmMsOfs= X-Google-Smtp-Source: ADFU+vu5vY283ASZRXAMon3qlw7ie0S1m5rWtW8ZWr/KGhXLOm2cYPjK9C09zCuPUe3oklGp4WasTG2a7y1cjtuMD1I= X-Received: by 2002:a54:4085:: with SMTP id i5mr595339oii.17.1583782174769; Mon, 09 Mar 2020 12:29:34 -0700 (PDT) MIME-Version: 1.0 References: <5e6696ab.1c69fb81.eb10c.68c2SMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5e6696ab.1c69fb81.eb10c.68c2SMTPIN_ADDED_MISSING@mx.google.com> Date: Mon, 9 Mar 2020 16:29:23 -0300 Message-ID: Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000edc61105a071057a" Subject: Re: [PHP-DEV] Re: [RFC] Attributes v2 From: david.proweb@gmail.com (David Rodrigues) --000000000000edc61105a071057a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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. Atenciosamente, David Rodrigues Em seg., 9 de mar. de 2020 =C3=A0s 16:19, Andrea Faulds escrev= eu: > 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 when > 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 normally > 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 be > expensive anyway, possibly moreso. > > On a different note, the wording here is syntactically ambiguous. It can > be read as both "if the provided attribute arguments are fullfilling the > contract [=E2=80=A6], then no validation is performed" and "no validation= is > performed as to whether the provided attribute arguments are fullfilling > the contract". I read it as the former the first time, which confused me > 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 > > --000000000000edc61105a071057a--