Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111248 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17628 invoked from network); 29 Jul 2020 17:33:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jul 2020 17:33:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 48738180088 for ; Wed, 29 Jul 2020 09:30:04 -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,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2076.outbound.protection.outlook.com [40.92.21.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 29 Jul 2020 09:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WgARvAAnz6s332f4IyaAPxr2WxzTaRmilNdllqdh9w272KF2uk4qBpKOzF+I7KQ+r5f4zNPHyKKg6nnC6YtiJCjQbxkNdKGG5B/dUD/HO8FFqTyIJEEwOVuNnERdKh+LxJnEXICvK77D2Yc34lfTYTvjsNSzVvuxPIBdH3uxtT7K5/qIHWHcY22H82hExwoFVTpMKVLx8/ICaoeBJ40iOIo90iHJNM3R1pAvMe7Jq8jhMx0RWsFJ2M4mI9ApO2v+N42sLJHQ/m6E1uyPB48ph0L5wP016tT0PRi5lp7qO0ML9yNxPdy5qR/raf0vCb3Htg0Ubq3vPxNr85VY95Vy1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wI5ioghsyD+1Qj98mAkbd6iiLsJAJ45saJaXz4vd/T0=; b=l/WH+fcvaRhfnuEG2diWO5h4mQCLeLsis/RcdzfJa+H6JSPQveQN1cec2y2bmncTHeBLXkqIg+m4jmQ00jKmM89brPxlx1npN7k5iHIcKju+Cv11PrdsJ1uz+8dCKxkhqC7z53+Wi3W4TD4XGNH9wIBpNjON3CYH4+DYXJO5V1ulWvmCYwkilaNjbi7L6S6m/LWuDMHQfIV57x7UM9hnS39eQr6rOtWED0e3/QOj5TLVF7e61WTrJ08IQG/IYMw2Jq1UMYTyKfVVAAbZyGCgbFh8qvC1d3KolfSUhXjsT7V5YMSbrqVeZh8tCWWYPTTp1euMe+CaKWnvZtoiki/Chg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wI5ioghsyD+1Qj98mAkbd6iiLsJAJ45saJaXz4vd/T0=; b=jO9ovACEaxvwxv4UUH0yCJ+H8p/chNg75oYbGIaNNoAUUSEoCIlogERm/3BMZqmZIhQSAP8NULE46cUjDjKxtNA+2JNZJlrWkqMP87CBEPW5nlIkg7nv+r11JHh5xYLGEMK6m9ZsUxKQwFBA6hjl7Dw4SJy4xDr84C6orPKDxuQGpAjdjv3LZvy9/vP5rUDGFPLKwCxiX8jO3s3uL/SJEY2WaoxXpXVrKB+Xmz0iMUW+DK0oZfrYoZoDTE6TjtpRRoaYQELusos7/oAzRErOsTlWUq6uvVmGahTccVGsAepMBUFq/3Kw+uejoYioH2vcEOJe22HEpzoNCt2No4yOrQ== Received: from BN8NAM12FT060.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc66::49) by BN8NAM12HT130.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc66::485) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.14; Wed, 29 Jul 2020 16:29:58 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:fc66::48) by BN8NAM12FT060.mail.protection.outlook.com (2a01:111:e400:fc66::430) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.14 via Frontend Transport; Wed, 29 Jul 2020 16:29:58 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::cc10:a3e2:1dcf:adc1%6]) with mapi id 15.20.3216.033; Wed, 29 Jul 2020 16:29:58 +0000 To: Joe Ferguson , PHP Developers Mailing List Thread-Topic: [PHP-DEV] [RFC] [Discussion] Shorter Attribute Syntax Change Thread-Index: AQHWZO4I0QL2FiMxn0qlAoSLzTT8dakeumQj Date: Wed, 29 Jul 2020 16:29:58 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:5244ECAFB51B39B600FCCC9A7C1A07D87B474C60FDF9F172D0B696A8F495299B;UpperCasedChecksum:116F41179322E7B8AABA438CC0B4A9DB5507D93545EF731703E5BD369444C00C;SizeAsReceived:7113;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [32ZJeSGcTFJPVnhNAsKmk17/BFEulQZuxnTXBcPNfoCe5W9NFLF0NjJfmYpLOW0W] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: ef06050b-2307-45f8-9824-08d833dca257 x-ms-traffictypediagnostic: BN8NAM12HT130: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: o9ehS1S9u3mwFamjKGpUZaxLDRoC5S2FT3lKICbfC08mF0qcWpdYgb3WjVe/+UCu3lwYvjTNmShbSpT6fPtqc4o0fcS/rngbQZH1e66jzs27+2rPLSJa0xiTs/WDMcV39dNmkUGsjWD1mMnX7xUo0FJBGXT7fH6A9LmJO2w9nuqqv/cevD+nvzmwdXk5sDtsHWF3ZeNLuZkL0mgVU+IxnA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:0;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR07MB6618.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:;DIR:OUT;SFP:1901; x-ms-exchange-antispam-messagedata: 3xHMASw7POCa5KQ/if37GzGwk5RZmO2SnSOM7uGP9qdOYNp99keWOgCAyJVWBW07kTSQobk1ivlOKNSwYWD5qhuNYs87jix/wAn6GaS5VvPBISB76t9hSXdneUj3wLRmj4zv43VNBx/KMhD0cLB9Rx3vmxhlxFfQ1oCVLJzfARBPBdunp7Zq5UW9yH166nBnBYAGMkYA9tPorwZ3Zmb3yA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN8NAM12FT060.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: ef06050b-2307-45f8-9824-08d833dca257 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2020 16:29:58.1556 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM12HT130 Subject: Re: [PHP-DEV] [RFC] [Discussion] Shorter Attribute Syntax Change From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= I had thought of another alternative syntax - `/** @@MyAttribute */`, which= would solve some of the problems I mentioned about `#[`.=0A= =0A= ```=0A= namespace My\NS;=0A= use Other\MyAttribute;=0A= /**=0A= * Use @@ or << at the start of a line. (To be determined)=0A= * Resolve the names in the comment relative to the scope of the function, = like the current attribute implementation.=0A= =A0* @@MyAttribute(expr, expr)=0A= * Extra *s are allowed=0A= *** @@AnotherAttribute=0A= * Tokenizing should continue until a matching ) is found=0A= * @@YetAnotherAttribute(=0A= * expr=0A= *)=0A= =A0*/=0A= function my_function() {=0A= }=0A= ```=0A= =0A= Pros:=0A= - Doc comments are already the recommended way to associate information wit= h a named element.=0A= - Most code modifying tools will preserve doc comments=0A= - This can go on the same line as a closure/short arrow function without le= xing ambiguity.=0A= - Frameworks can use `Reflection*->getDocComment()` and update their checks= to also allow `@@` for attribute-like annotations when run in PHP 7.=0A= They don't have to repeat both `@@MyAttribute` and `/** @MyAttribute */`= or risk it going out of sync=0A= (Symfony would already have to parse the `use` clauses to find out what = `@MyAttribute` resolves to for Symfony attributes)=0A= - Does not affect lexing outside of the doc comment=0A= - I don't believe @@ is common. To minimize the impact on ascii art, this c= an be initially limited to @@ at the start of a comment line (spaces and `*= `s) immediately followed by \ or the start of an identifier=0A= =0A= Cons:=0A= - Need to run the lexer twice on a T_DOC_COMMENT token, but only if the com= ment string contains `@@` and is associated with an element.=0A= Emitting T_DOC_COMMENT_START and T_DOC_COMMENT_END and T_DOC_COMMENT_INN= ER and T_DOC_COMMENT_ATTRIBUTE=0A= T_DOC_COMMENT_ATTRIBUTE_ERROR might make this technically feasible (simi= lar to heredoc having complicated logic)=0A= - I prefer `@@` and `<<>>` over this proposal long-term, after php 7.4 supp= ort is dropped.=0A= But I prefer `/** @@MyAttr */` over `#[MyAttr]`.=0A= - Would end up emitting parse errors for some existing code in the second l= exer pass.=0A= - Syntax highlighting might be hard to implement in editors, but probably t= ractable.=0A= =0A= I don't remember seeing this proposed before. I believe @@ isn't used by ma= instream frameworks in doc comments right now, but correct me if it is.=0A= =0A= Thanks,=0A= - Tyson=