Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111508 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 77408 invoked from network); 13 Aug 2020 18:22:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Aug 2020 18:22:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB1C91804F2 for ; Thu, 13 Aug 2020 10:21:58 -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 NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11olkn2023.outbound.protection.outlook.com [40.92.20.23]) (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 ; Thu, 13 Aug 2020 10:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDoBvhg7KwB1twoQre9AYpMPsJCEabkhDaxihl63DaTcz1jsh9Xux9wmJ2W/g+Npj10XjyJNih7JHEbNvCZOEadMGqS5KvEFEECPw5/tKgsxQ4/rllkAo2HRZ1AwcT2ZxJ6VVc68RJP6LqQ6SF5ZajmRsLN/4PZirYBufso4Xv8ne++jbLC/f6ActjtIJzZMpa8OLecfy0KdjEl0i+PUQB8se3e1WUvUM/wSuhiaNCKThxSnP1k5zoBIDhHKNGDBbwOG2K1+gExv4TYqpFSAIh7bpVPYZXgg4OXWKRwvfNzZJcUJXR//DkAy76VdntlVOA1pQGYGiQOaiu871nfapg== 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=Ly5gbkJS+52C2MnmYR8g40P2gvIdYMYJH2miZmbMR/U=; b=SuWhBvO/HRamrdLo2FX1H3ocmiZIr2HBiGcsSzqY0MXKquC/g3D1Pr79FGLICcbKEfFTs6vLkPSg1CRWb3s3ODtx9vaUaq9l/8g4iSgyFI9J4TMBXwpI6gfFfTDcnuVcHDnRgaHvjJTWa5l4CLkGzHMb53ohSqHfci3VjeVtpQm1RvektFl5WlPFnmUgaJe9ipi+CcTCPSycI3K8PR5WxS+3d8Hm2yIIjhN59YJwgDlIbN73eKYw+GbABCNVYyJv7KBXYEZqiH2UxTJkCAKPH1RvmSwASW1SbVRGIAJ/hg1EicLEAvf7PNExKbYLv9zgnEaB/r/x3A3Fn/U9Tb35/Q== 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=Ly5gbkJS+52C2MnmYR8g40P2gvIdYMYJH2miZmbMR/U=; b=Hzfr+zqjIDwtC4C2JG7OdehOErqJznvEqal1I7yHL7qb8NH8s32JsuEq4clu1P7l2xrEwBfNpbTsDd4O2QhxLj5bhKDji9ihhcsz2SbHfkfnhMTLA0QwXgUCmGFR0CyCxTlxlzLY5ieitnN/jG+9s9CJAWSNB7wRR8sCa3RZZlng3Rq2YsoGUAG854LdwoN7+L1236EOhQirQ749ovOXCkpsKATqAsQH+7IMYtvB36vQ1ppnEiRUDWKRz8dfGx1UVi7YDdRJvbHdnFMlGR2sSy0NOWaMcTks+aqkLsEizhM47y2/na5v9562wTjhtHbsg6INMWtUdo1HicgXWr1buA== Received: from CO1NAM11FT065.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::51) by CO1NAM11HT118.eop-nam11.prod.protection.outlook.com (2a01:111:e400:3861::337) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Thu, 13 Aug 2020 17:21:55 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:3861::4c) by CO1NAM11FT065.mail.protection.outlook.com (2a01:111:e400:3861::62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Thu, 13 Aug 2020 17:21:55 +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.3261.025; Thu, 13 Aug 2020 17:21:55 +0000 To: Derick Rethans , PHP Developers Mailing List Thread-Topic: [PHP-DEV] [VOTE] Shorter Attribute Syntax Change Thread-Index: AQHWbvIF7KrSF3HLUE2WaV22ixIGaKk2RucY Date: Thu, 13 Aug 2020 17:21:55 +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:83A4311712FD9472DA6AEC999878B482DC0D32FF723B946D538B5EEAB20D7E1F;UpperCasedChecksum:DA2CE9DAF01812B60F95D25DECF84A572EF0D1378AD06B00B6E680DA068DDA11;SizeAsReceived:6928;Count:44 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [d0ZZmmMDMeALMXcC9EeLRbp5DwZBrqki] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 317c1a0f-2fda-4367-71ed-08d83fad608a x-ms-traffictypediagnostic: CO1NAM11HT118: x-microsoft-antispam: BCL:0; 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;SFS:;DIR:OUT;SFP:1901; 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: CO1NAM11FT065.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 317c1a0f-2fda-4367-71ed-08d83fad608a X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Aug 2020 17:21:55.4043 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM11HT118 Subject: Re: [PHP-DEV] [VOTE] Shorter Attribute Syntax Change From: tysonandre775@hotmail.com (tyson andre) Hi internals,=0A= =0A= One thing I hadn't thought of=A0before was how this would interact with par= ameters (with or without constructor property promotion).=0A= Many coding styles would end up putting annotations on the same line for pa= rameters (in addition to closures)=0A= E.g. I've commonly done that and seen that done in Java:=0A= https://stackoverflow.com/questions/30237266/java-parameter-annotations=0A= =0A= ```=0A= class X {=0A= public function __construct(=0A= @@MyImmutable public bool $x,=0A= private bool $flag =3D false,=0A= ) {}=0A= public function __construct(=0A= @[MyImmutable] public bool $x,=0A= private bool $flag =3D false,=0A= ) {}=0A= // This comments out the first parameter entirely in php7, silently lea= ding to different behavior in php 7=0A= public function __construct(=0A= #[MyImmutable] public bool $x,=0A= private bool $flag =3D false,=0A= ) {}=0A= }=0A= ```=0A= =0A= As Theodore said, this RFC doesn't include enough examples to give a compre= hensive understanding of how #[] would be implemented and what the implemen= tation implies, which the original shorter attribute syntax did https://wik= i.php.net/rfc/shorter_attribute_syntax#alternative_syntax=0A= =0A= (e.g. this gets parsed as `$f1 =3D $f2 =3D $object =3D new foo();` in php 7= and would not warn with your patch (from the mailing list) in php8. No pat= ch for #[Attr] is linked in the RFC document.)=0A= =0A= ```=0A= $f1 =3D #[ExampleAttribute] function () {};=0A= =0A= $f2 =3D #[ExampleAttribute] fn() =3D> 1;=0A= =0A= $object =3D new #[ExampleAttribute] class () {};=0A= foo();=0A= ```=0A= =0A= Even if the RFC was amended after the vote was started,=0A= I don't think that people who had already voted would see the changes or re= ad all of the numerous emails in this thread.=0A= =0A= > Changes lexing of remaining tokens indicates that a newly introduced toke= n changes the behaviour of existing tokens.=0A= > In the example of `#[` the occurance of a # would have previously always = signified a comment, but that now changes to become an attribute instead wh= en followed by `[`.=0A= =0A= That's similar to saying that the `??` token would have previously indicate= d a `?` for a nullable type/ternary, but would change to become a null coal= escing operator when followed by `?`.=0A= It understates/omits mentions of the changes to lexing this can cause, whic= h I mentioned in https://externals.io/message/111218#111239=0A= =0A= ```=0A= ?php=0A= // This example echoes the rest of the source code in php 7=0A= // and echoes "Test" in php 8.=0A= #[DeprecationReason('reason: ')]=0A= function main() {}=0A= const APP_SECRET =3D 'app-secret';=0A= echo "Test\n";=0A= ```=0A= =0A= ```=0A= // yields false in php 7, yields a function in php 8=0A= function generator() {=0A= yield #[MyCustomAttribute('=0A= false;=0A= // ']function() {};=0A= }=0A= ```=0A= =0A= Regards,=0A= - Tyson=