Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111393 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35431 invoked from network); 9 Aug 2020 16:39:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Aug 2020 16:39:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1B76E1804D9 for ; Sun, 9 Aug 2020 08:38:01 -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_50,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-vs1-f66.google.com (mail-vs1-f66.google.com [209.85.217.66]) (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 ; Sun, 9 Aug 2020 08:38:00 -0700 (PDT) Received: by mail-vs1-f66.google.com with SMTP id i129so3081753vsi.3 for ; Sun, 09 Aug 2020 08:38:00 -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 :content-transfer-encoding; bh=yBvdBCsHPexs0I30bbXNNB+dO7tKIgm4//uU03tnWF8=; b=tIoZWEnoF+ZJQhE5loV+0C5gsS56w+mwOYH8848kyl29Zl6JxhZfHhS1sPTFhcErgQ JpzgOAlRlncHIfIKtuj+Z/DiMTLt9liSu4JyKW0OlJU8g/f6kLvfoFtphQov1o030aEA dwrA9l+/TOAJeNBcKQWEUGFGxCo8ZOF9km8MwmSy4ugOJInNs6vBoK8KeRCUN6oitLyU 9oSaFM/sVejn5GBELIwDg0ba2L1mYaKPxcnaX5QZvYYE4f1LvnBGNxmwoEPuMcXsPVCZ 4XHyuecZPEsinFIHwCUlEZIrq2lqQ0gqEoVEo6JRZM+HyVcQO+hP17+rTMGrg8VfR4Ol E8Qw== 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:content-transfer-encoding; bh=yBvdBCsHPexs0I30bbXNNB+dO7tKIgm4//uU03tnWF8=; b=h8DnJibxXdYzYzfvMly99d0j2QJRXsLh1ED/E1rOu1wo/VyTXtU9gz4tW3t0b6g25H Pm83g9Sc+U33NavaWuG7UmPsFaS0Gv115z5GBvEQZ4QBY+/i+EpHhDmAxXLUNmLmhgqe 2FRzfCfsFnQRlQmUCpGsu7iZOvEWT6OP/G3JH1r6KpqSIDFAwEk5RrSUndEw1SV16Cmf miziOYl/j9+6QBnn34/LKWtH+Bn4Vatk+gohFbt8QJqP4Ol7Rz5pON1AKcOTbbM2zzYi G2wbggDNWuiaYLWtO+R86ytzkS8OThX6Tlf0fX7c1xekEedkeqv3zZGBM/Qsv9IorAHy XG4w== X-Gm-Message-State: AOAM530IKid7Z7L1c9P3o9PLpy80raKUJ1vuVK+QQyvgeMbXB0BA/ePb mSsLUTNiZ6hDQPiQ3OK4SGFpHFciXX4i5H6ODxRX2+XuhSXd6Q== X-Google-Smtp-Source: ABdhPJx24h/s5elNMHZRdwKCExMoVM3kFRiGiHVlXNRnISOpiQYfp8vQL3BmbGaeaEnpOUVHuHAJDEef8aWWR4CiBHY= X-Received: by 2002:a67:33d3:: with SMTP id z202mr17719305vsz.130.1596987476178; Sun, 09 Aug 2020 08:37:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 9 Aug 2020 17:37:44 +0200 Message-ID: To: PHP Developers Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Shorter Attribute Syntax Change RFC 0.2 From: k142es@gmail.com (Kamil ES) Hi everyone. I=E2=80=99m not a PHP internal, just a modest PHP developer. B= ut I felt a desire to share my observation on =E2=80=9C@@=E2=80=9D. Some symbols looks very okay when doubled. For example, we use =E2=80=9C//= =E2=80=9D for comments and =E2=80=9C||=E2=80=9D for logical alternative. They are okay, because th= ey contains only two parallel lines. There is a symbol like that in mathematics: =E2=80=9C= =E2=88=A5=E2=80=9D. Programmer fonts (for example Fira Code) convert doubled characters to an appropriate ligature. On the other side, the at sign =E2=80=9C@=E2=80=9D contains the small lette= r =E2=80=9Ca=E2=80=9D in a circle. It=E2=80=99s feels full to the brim. It=E2=80=99s complete and closed whole= . It=E2=80=99s like a donut with tasty filling. ;-) But when we double it, the resulting =E2=80=9C@@=E2= =80=9D is bloated. Even intuitively not right. Why =E2=80=9C@@=E2=80=9D was proposed? Because =E2=80=9C@=E2=80=9D is alrea= dy taken. Sorry, but it=E2=80=99s born out of helplessness (in the most visible way in comparison to other syntaxes). And maybe this is the reason why some of community members feel bad about it (no matter of technical arguments). One could argue that it=E2=80=99s a matter of taste. Well, only to some deg= ree. Mankind invented typography and editing, so rules of esthetic and harmonious writin= g exist. PHP has PSR-12 (=E2=80=9CExtended Coding Style=E2=80=9D) for this. Now I=E2=80=99d like to draw your attention to this syntax: << @Assert\NotNull @Assert\Type('string') @ORM\Column(type=3D'string') >> private string $username; It has some good points. First of all, it uses single =E2=80=9C@=E2=80=9D. = This is a popular choice in other programming languages, including JavaScript =E2=80=93 a nat= ural companion of PHP in Web programming. \ Nesting attributes in this syntax is very natural. The mental model of the syntax reads like that: Here I put =E2=80=9C<<=E2= =80=9D and it starts a metadata (metaprogramming) context. Now I put =E2=80=9C@=E2=80=9D for eve= ry attribute. Let=E2=80=99s finish it with =E2=80=9C>>=E2=80=9D. I like this separation of metaprogrami= ng and a real code. It=E2=80=99s something that remainds me DocBlock. The syntax has it=E2=80=99s weak points, of course. For example, a single a= ttribute looks a bit verbose. A good syntax highliting may help to blunt this impres= sion. <<@Deprecated>> public function doSomething() Moreover, the more spaced syntax may be preffered (and I like it more): << @Deprecated >> public function doSomething() Another option would be to use a keyword, just like =E2=80=9Cnew=E2=80=9D w= ith a class name. meta Assert\NotNull meta Assert\Type('string') meta ORM\Column(type=3D'string') private string $username; Going back to nested attributes, what I don=E2=80=99t like about =E2=80=9C@= []=E2=80=9D and =E2=80=9C#[]=E2=80=9D is that the at sing is at first before brackets, but for nested attributes it will = be put together with an attribute name: @[Attribute(@NestedAttribute('text')] I believe this RFC should have an example section to show every syntax in practice. Best wishes to all of you.