Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111239 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45242 invoked from network); 29 Jul 2020 01:25:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 29 Jul 2020 01:25:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C2F461804D0 for ; Tue, 28 Jul 2020 17:21:33 -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 NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2063.outbound.protection.outlook.com [40.92.41.63]) (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 ; Tue, 28 Jul 2020 17:21:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iKXWrutlYBOgOC1idDhBcQLlkFU53G5U3lcXxABaIUpQuwZdAglHN7g4HBLunAK3MkQmZrGRsgzsQosUVKKN4qnUK8iOVQqjTT+BSYGlR3KWhGKgFU1/T4jCDv/QjYwwo0AkatMPtjKu8GGbH3Ht/BvCfnwoJ4L+r25ecE4IhY+RspwloivuOHPN5lEnGMcbPSRF3zRb21CjSDWYc/O5dcBLtPQonKkg71jLO+JJil4gVD+vUoQsDhRQWHDXQffNo6cMTWn8TzMcLDeBWZgGcYT9j8gsTqH91fP8oJDOmFcYDZp5y8USBGWhF/31vcgfjo35+oVg8EvYKpuJ7H5u1w== 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=BzXY3mS3bdxIMyh4qRC5PWGkV/ki+JzieSCCgeKKuHs=; b=dLdca+xi5sme0bH9IEtMwDvmIaCOA/A2PgM9r9rFINZOi425JaMzMKbOxgbjNp52gR6txXZDZr87jBCzABiFzrSFg+GRTlii6YPtnMAviQTvDOIcpcZurMV54O+LCobZwASmTtF1nmRLBSuW68goM6agslTx7IJnQ96VjARM6Jfx4RlLRixiFbnPJ5PhF8cACYVTUsHKIm8xLntt+CLpBGl0qBAhG+gpOLrsZZhaTF4yqo1iIvMvL7Xs1wwYC0yK4pTuMx9/cIl/q7mVgYU6d4yeIUDhYyJiASumEPWNOGGQVrm23jDeK1DNfOPNMZkgsBGoIERza3c7/eSqh29BcQ== 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=BzXY3mS3bdxIMyh4qRC5PWGkV/ki+JzieSCCgeKKuHs=; b=oDRbYGMr19SzzNCyD2uMhGBlQ6NDwUCdpQXKWzRkiVGTaush+xLVKo3qo5aV9y5NKvjaBCsV+Ex9NBvmS74dv/yWtqaC2GP2er5vuLWqHEAUpGPkewfkDfIuosoEuFpPoQb0crlNh93fNnowAqKdrhR+CcPf7gpKEeJwQ4pn/oBtjhr0tUIt/IvDTgiPbD/Xco49EN66V/R/aw3vSMK3PgZ7PckSL2VcqeIeiI134+v1+9qw1vnpyYFJ41dJ/NZXEk1YywmwEKzuzZrTkv1w3maMnpoRQ0BsBfIoP6hoE/OxPnsD78VpEZYwnpIhUQ/AqMkPbz/POWEGK6uvuQ5PGw== Received: from BN7NAM10FT054.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::48) by BN7NAM10HT064.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::307) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10; Wed, 29 Jul 2020 00:21:31 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:7e8f::49) by BN7NAM10FT054.mail.protection.outlook.com (2a01:111:e400:7e8f::368) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Wed, 29 Jul 2020 00:21:31 +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 00:21:31 +0000 To: Joe Ferguson , PHP Developers Mailing List Thread-Topic: [PHP-DEV] [RFC] [Discussion] Shorter Attribute Syntax Change Thread-Index: AQHWZO4I0QL2FiMxn0qlAoSLzTT8dakdpGAp Date: Wed, 29 Jul 2020 00:21:31 +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:1D2070010DE2FA84FD49E36EA313A1F08BA7483750AC97B0249A0CACDFD940E6;UpperCasedChecksum:6144AA1C1C75BCAE42560AEE6E9A5F7C4AB9C851967B3173D4060D0AEABE73A8;SizeAsReceived:7109;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [UTLo+KDEVbkO5bgetyFADWf1CZHIIYkNErTtM/9qYJ5rN+9DfKbI7Jltyh3zVU8r] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 2e3ce689-b7ba-44a0-5878-08d833555800 x-ms-traffictypediagnostic: BN7NAM10HT064: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rt+7PbL8FHgb+PHjcDvBvLHUtgKJp1G+UawrHMswwhJan2lfMp/0PgRq6ANKDnMju1NTEdSvIv3yZOYonKEK/jvIQA1lK3i81zowSNBye4riJ2N2DV1LsNPvHSpc6Ykw+mDjZ8UvmPfzn1PoXLIFfZUOSfCcBtROVc5RKKikyUaOQ8mmPNcPJoVVxhfuOFeC9ccYtEo8RRgwLzczRH2WXebyVdTjBH+bCzxm2oOLriaocY9VPHbinEj77d/B411x 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: zPpyxOr72H3ft0rSkM2vEOLnyqIkWSLP8v0v8QiDxz1ptnh+5NRkQtS1zYELZ5DHcMnih0gPHQytJqAQswDYhjPhYZm6ngMG8G0CMvuUY1TEiqeb1VnqhJzCNRBsyyvRNQUmgHL7cBWgTFIDXs8SRNuygwdJcHvugqkIAnLxyYfGh3gHLAs5QygeXuaBfbSUlsUnNnhh/az1y0DigQ9Ipw== 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: BN7NAM10FT054.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 2e3ce689-b7ba-44a0-5878-08d833555800 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2020 00:21:31.3730 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT064 Subject: Re: [PHP-DEV] [RFC] [Discussion] Shorter Attribute Syntax Change From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= For #[, my main objection is the various ways this can change the lexing in= a way that is impractical to (efficiently) backfill,=0A= and that the proposed patch doesn't address the fact that the syntax may ch= ange the syntax of php 7 code in unexpected ways. =0A= =0A= This syntax would help phpcs with easy examples **in the short term**, when= attributes are on a single line,=0A= but would make more complicated refactorings buggy and error-prone unless p= hpcbf was run in the same major version.=0A= When attributes span multiple lines, the lexing is completely different for= `#[]`.=0A= For example, the below syntax would yield false in php 7, but a generator i= n php 8.=0A= (There's precedent at least - the lexing of heredocs changed in php 7.3 or = 7.4)=0A= =0A= ```=0A= // Aside: This code snippet seems to have an assert failure in the lexer wi= th the patch in the RFC=0A= // Zend/zend_compile.c:1794: zendlex: Assertion `!(executor_globals.excepti= on) || ret =3D=3D T_ERROR' failed.=0A= function generator() {=0A= =A0 =A0 yield #[MyCustomAttribute('=0A= =A0 =A0 =A0 =A0 false;=0A= =A0 =A0 =A0 =A0 // ']function() {};=0A= }=0A= ```=0A= =0A= And another example which would cause problems for phpcs in php 7 - the com= ment syntax can cause code to be treated as inline html instead of php toke= ns.=0A= =0A= ```=0A= ')]=0A= function main() {}=0A= const APP_SECRET =3D 'app-secret';=0A= echo "Test\n";=0A= ```=0A= =0A= I'd posted another example in=A0https://externals.io/message/111101#111133= =0A= =0A= One way I'd thought of to avoid this ambiguity would be to assert in PHP 8.= 0 with an E_COMPILE_ERROR (or E_COMPILE_WARNING) that:=0A= 1. All tokens of the #[...] annotation are on the same line=0A= 2. No non-whitespace token follows the ] on the same line.=0A= It may be permissible to allow other `//` comments or multiple attribut= es after it on the same line, though.=0A= 3. No `?>` substrings within the rest of the line after #[, maybe=0A= =0A= Although I'm not sure if others are actually concerned about this ambiguity= and these are really artificial examples for code.=0A= =0A= As for `<<`, I'm assuming people may have meant `yield <> function() {= };`,=0A= but `yield` already has a precedence and didn't have issues - otherwise `yi= eld+2;` could be adding 2 to the result of a yield.=0A= (It's unambiguously `yield(+2);` right now).=0A= I forget how it'd be parsed, but it wouldn't be ambiguous.=0A= =0A= As for `@@`, all of its known issues seem to have been resolved,=0A= and there is still the potential for future issues, but I still prefer it o= ver the `#[` implementation in that patch.=0A= =0A= P.S. I'd like to note that=0A= 1. A lot more discussion has occurred since the initial vote.=0A= 2. Since `@@` was obviously passing at the time, fewer voters would put muc= h thought into detailed tradeoffs of `#[`=0A= 3. I haven't seen those specific drawbacks to `#[` of potentially significa= ntly changing lexing (not just losing tokens) mentioned,=0A= but the shorter attributes syntax RFC did seem to mention params were co= mmented out.=0A= =0A= One idea I'd have on voting would be to have the exact same 3-way vote, aga= in, and pick the attribute syntax with the same ranked choice procedure.=0A= I assume proponents of `#[` would have similar objections if an RFC with a = two-way vote for `<<>>` and `@@` was started first.=0A= =0A= Regards,=0A= - Tyson=