Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110450 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 67486 invoked from network); 9 Jun 2020 15:38:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jun 2020 15:38:58 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 855C31804CE for ; Tue, 9 Jun 2020 07:22:39 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE 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-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 ; Tue, 9 Jun 2020 07:22:38 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id e1so21560917wrt.5 for ; Tue, 09 Jun 2020 07:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pWVQsSh7qkpVYPxAKYaoNRcoTIgwDjct9yYouq8k1dk=; b=byXm6PmFtef0i8dmROXJ5O+9qKLvgoBAC/Nq4qzH3db/9NwDI/1XmdoVMpn/2r8EM+ 7unDiRTlQ5vauyNiYkOYN0meTVNGF6fj+j7NBDgPz8gRHEGswRPnc+HsUO+jfC6IUsOm PpjYB4EpTOCVcMRLQCWH1mi4pZcIHjf1LM8+HdJSBOnUDro/y2usgZw/lLrpWAZ5F4fq A2d6vSlbFE3n9Wv78PoxBqPSWae7Ty4lO8m/XiNi3qEa6GEg4emxdqpgz9l6at/avKeC ipSbODi9uLa2pdQ/ekDOsQAlNmxjD2MhU/0qj0a80U0xtp34z8vHC706bfYqb6urXZ6E NMXQ== 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=pWVQsSh7qkpVYPxAKYaoNRcoTIgwDjct9yYouq8k1dk=; b=UbSZA7bksgAQOY5NkjOlzluNNNEZxIdryYD1YJ487GNlDmFtQFmdXNXvvsR5XF2kZw jGqvHQ14k5hfM2am5IQZLPRgD/ErreEviYYg/SOvvYBVNykBUuyZlzyz+WvAGjJ8QbJ2 qnubzFsUcVLES5VmVO33T7VTqxq3Li0iWmw2PuQ+AByGgOJ2w3pxcRXy2BwEJlHEi03P 49ZEBjtVw0QZNRv89Ax9RuBUghdctyZo3ClJfvSGplq8QnCuAxtD+c4xOI1g5dEUT1Z/ nRnGHXFdht+oPzKy7mwAoi9pkD4zWMZ6Wht6lWRUNUP0hDobTIxgyMJXDUHi2Zeit1Lr A5Sg== X-Gm-Message-State: AOAM531ZEqFTBKf76ngrJwOGSBjzsLvVatwSWhRx2wEEwsNRUtrymZUl PhggENj8rxc2gzLp3zSB4xGxc0RRRRDoe18ojsM0oA== X-Google-Smtp-Source: ABdhPJxof6dblq9EnzSxmURDKK26a2XdHCDBypwZDQm3FTY3s6QFkIv2sEHx2yUevW7ncth0OYw4E6uW3VlgJgoBoNo= X-Received: by 2002:adf:dec5:: with SMTP id i5mr5086450wrn.16.1591712554794; Tue, 09 Jun 2020 07:22:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 9 Jun 2020 16:22:23 +0200 Message-ID: To: Lynn Cc: Theodore Brown , internals Content-Type: multipart/alternative; boundary="00000000000069d8e905a7a7758f" Subject: Re: [PHP-DEV] [RFC] Shorter attribute syntax From: kontakt@beberlei.de (Benjamin Eberlei) --00000000000069d8e905a7a7758f Content-Type: text/plain; charset="UTF-8" On Tue, Jun 9, 2020 at 2:07 PM Lynn wrote: > > > On Tue, Jun 9, 2020 at 1:55 PM Benjamin Eberlei > wrote: > >> Larry's suggestion about #[Attr] makes an important argument about >> allowing >> to declare attributes in code in PHP 7 in a forward compatible way that >> has >> not been brought up before. >> >> /** @ORM\Entity */ >> #[ORM\Entity] >> class User {} >> >> This code would work on PHP 7 and 8. >> >> The #[] syntax would have about equally low breaking potential as @@. It >> would be the same syntax as Rusts, and close to C++/C# syntax. >> > > Hi, > > The idea of making annotations forward compatible in php7 this way has a > big + from me. I honestly don't mind the syntax too much. How would > multiline notations work with this? > > #[ORM\Entity( > arg1, > arg2 > )] > > This notation would obviously break in php7. Would it be possible (in this > case) to do something like the following example? This would have php7 not > care because they are comments, while php8 could filter the # out and make > it a valid annotation. > Good point. The forward compatible syntax would need to require single line declarations as you suggested, because the multiline syntax as you rightly show is not valid php7. The alternative would be requiring each attribute line to begin with #, which I don't particularly care for and would probably be a mistake. > #[ORM\Entity( > # arg1, > # arg2 > #)] > > I'm also okay with having everything on a single line, just wanted to > point out this might cause issues. > > Regards, > Lynn > > --00000000000069d8e905a7a7758f--