Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111363 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56973 invoked from network); 6 Aug 2020 18:32:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Aug 2020 18:32:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5AE35180568 for ; Thu, 6 Aug 2020 10:30:29 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (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 ; Thu, 6 Aug 2020 10:30:28 -0700 (PDT) Received: by mail-lj1-f195.google.com with SMTP id s16so37447273ljc.8 for ; Thu, 06 Aug 2020 10:30:28 -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:to :cc; bh=n3lS9eSawNOTRj4BdTIA5bxU3/qFXPGEVJ9qk0+Ujj0=; b=ciKOOc4hwT95R4g8R88XJNN4Py2QNvTgFk0d1jrGI2Dtbaepek493IVpUVIwOn9ONd ce27CSbPUuiA4LHyemZ19sx2+JU8KKAnl4Z5imy3aKhMmEbj4G9+m91czAuB/IuXT1IN RMQwQwcETRCbfbuAi1Q1in36cSXnoBp4edyOkkhzAdL92n3Nd86zKFNQtgWdwfmnt7i/ 4cBtD0UF9AMAhTmmm33qrcezAOv2nCY4YGZGw8Mj1eg15qvzdc+rWTJXIxk/pS+JARBl edWPvMZunMOXWofajzW40Ur3awCI9yChjAMcUSg9uoaxyX6GlZPn9fnJ3nIFMIhUJgqa Vrug== 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=n3lS9eSawNOTRj4BdTIA5bxU3/qFXPGEVJ9qk0+Ujj0=; b=jLi5RQUaBb1agJ+w0aBPGwkios6korBucvAZnpljA5b0kfiGnrgIZBfCDRYnxnJZd/ qhMTOnoJcXN9qugfo7gcTg3gz+MLG237nFHzZlW00vuh5ubyFtoT1LYsePiS7RuPMf5A PtjEN2DDEjI8fAK3WtfO285pl2syDu5ADkgGYOkq7+WlSv3MibqLIA9+7+aLUZBMUDxB R12pPMIDeTn/dcRhvKhAVkfqp0nWWsBf2k2pT6dulCupFrjUQehns9YY/Yg8GiArjcrb z6xeFEnzxekBJbybjVTKQvwCi9+2NBLNoTMkGA1tITZDiXosJofu1Z/8A8rpxWdaNGUB dKqg== X-Gm-Message-State: AOAM531MvOOHYxGQWvpLJZKLk4qmaeYsXNJityO7vceIeddnVcpgyuFo lEd+Mu0Os08COWcyQT2j8cZzJNOQkgn8RMLDJFs= X-Google-Smtp-Source: ABdhPJyjPGVGrHMi7Apk3XpMJ392Vj17kRTrwAGFHF/NByIz1LUmpBkujpdPW6PjtPh2Vjh9dXUZU1tTJjDOsHaLiQ4= X-Received: by 2002:a2e:5811:: with SMTP id m17mr4399938ljb.96.1596735026548; Thu, 06 Aug 2020 10:30:26 -0700 (PDT) MIME-Version: 1.0 References: <20200806091749.64675445@mcmic-probook.opensides.be> In-Reply-To: Date: Thu, 6 Aug 2020 20:30:12 +0300 Message-ID: To: Theodore Brown Cc: Rowan Tommins , PHP Internals List Content-Type: multipart/alternative; boundary="0000000000000ed1df05ac38d8fb" Subject: Re: [PHP-DEV] [RFC] Shorter Attribute Syntax Change RFC 0.2 From: benas.molis.iml@gmail.com (Benas IML) --0000000000000ed1df05ac38d8fb Content-Type: text/plain; charset="UTF-8" Hey Theodore, On Thu, Aug 6, 2020, 8:05 PM Theodore Brown wrote: > On Thu, Aug 6, 2020 at 5:24 AM Benas IML > wrote: > > > On Thu, 6 Aug 2020 at 11:45, Rowan Tommins > wrote: > > > > > On Thu, 6 Aug 2020 at 09:12, Benas IML > wrote: > > > > > > > But by sacrificing a few very old codebases (that still use `#` not > `//`) > > > > > > Do you have some basis for # only being used by "very old" codebases? > As > > > far as I'm aware, it's not deprecated, and while the PEAR style guide > > > listed it as "discouraged", PSR-1 / 2 / 12 don't mention it at all. > > > > > > I agree that it is probably rarer than //... and /*...*/ but let's > avoid > > > unnecessary hyperbole. > > > A grep search was done by someone in the mailing list in the original > > `<<...>>` to `@@...` RFC thread when discussing whether `#[` is going > > to be a huge BC or not. > > > > Just about all of the matches were either from old codebases or from > > old PHP 3-5 Metasploit exploits, which are about 5-15 years old. > > Hi Benas, > > You can look at the grep search here: > https://grep.app/search?q=%23%5B&filter[lang][0]=PHP > > The first BC break in the results is from an automated pentest > framework repository which was last updated four days ago. So it > seems like this is still code that is being used. > I work myself in the cybersecurity industry and I can tell you 100% that the automated pentesting tool you're referring to isn't using any of that `#[` code actively. In fact, over 80% of the code/exploits stored in that repository don't work with new software/language versions. That's the whole point - there are hundreds of scripts in numerous different languages designed for exploiting only specific subset of software designed for only specific versions of PHP/other languages. By 5-15 years, I meant the exploits themselves. Even the current Psalm static analysis tests use # to comment out an > array: > https://github.com/vimeo/psalm/blob/afce2dc66ff83ccad3f3a7aa26740a5eb829b2ca/tests/LanguageServer/SymbolLookupTest.php#L453 > > Not that these individual examples are a big problem, they simply > illustrate that hash comments are still used in current projects, > sometimes in ways that the #[] attribute syntax would break. > ...and that can be fixed within 5 seconds. `#` comments were even deprecated in PHP's ini files in 5.6. > When it comes to the @[] alternative, it's harder to grep for actual > usages, since this string is used in virtually every email validation > regex. In any case, code like @[foo(), bar()] would no longer work > without putting a space between the error suppression operator and > array (which frankly looks pretty confusing): > > $x = > @ [Foo()]; // an array assignment with suppressed warnings > @[Jit()] // an attribute > function bar() {} > Same goes without saying with `@@` where `@@` means attributes and `@ @` means double error suppression. Albeit, that is not useful. > If there were some important language improvement that depended on > breaking these syntaxes, maybe it would be justified. But so far I > haven't seen such a justification. > > > We are playing probabilities here but at the moment, no one has said > > any substantial argument why `@@` is better and thus, `@[...]` seems > > like a better option in the long term. > > While none of our syntax options are perfect, I believe @@ has the best > long-term tradeoffs because: > > - It doesn't break useful syntax > Fair enough. - It is equally or more concise than grouped attributes without adding > complexity to the parser/compiler > Are we really going to debate that ~30 lines of code add complexity? - It offers a clean, simple way to support nested attributes in the > future if we so desire > I'm sorry if I'm not following the conversation but what is blocking that in `#[]`/`@[]`. - It is conceptually closest to the docblock syntax the PHP community > is familiar with > Well, if `@@` is similar to `@` (to me it isn't), we can say that `@[]` is also similar to `@`. - It is aligned with the attribute semantics of the majority of C > family languages > In what way `#[]` or `@[]` aren't? > Best regards, > Theodore Best regards, Benas --0000000000000ed1df05ac38d8fb--