Hi everyone. I’m not a PHP internal, just a modest PHP developer. But I felt a desire to share my observation on “@@”.
Some symbols looks very okay when doubled. For example, we use “//” for comments and “||” for logical alternative. They are okay, because they contains only two parallel lines. There is a symbol like that in mathematics: “∥”. Programmer fonts (for example Fira Code) convert doubled characters to an appropriate ligature. On the other side, the at sign “@” contains the small letter “a” in a circle. It’s feels full to the brim. It’s complete and closed whole. It’s like a donut with tasty filling. ;-) But when we double it, the resulting “@@” is bloated. Even intuitively not right. Why “@@” was proposed? Because “@” is already taken. Sorry, but it’s 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’s a matter of taste. Well, only to some degree. Mankind invented typography and editing, so rules of esthetic and harmonious writing exist. PHP has PSR-12 (“Extended Coding Style”) for this. Now I’d like to draw your attention to this syntax: << @Assert\NotNull @Assert\Type('string') @ORM\Column(type='string') >> private string $username; It has some good points. First of all, it uses single “@”. This is a popular choice in other programming languages, including JavaScript – a natural 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 “<<” and it starts a metadata (metaprogramming) context. Now I put “@” for every attribute. Let’s finish it with “>>”. I like this separation of metaprograming and a real code. It’s something that remainds me DocBlock. The syntax has it’s weak points, of course. For example, a single attribute looks a bit verbose. A good syntax highliting may help to blunt this impression. <<@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 “new” with a class name. meta Assert\NotNull meta Assert\Type('string') meta ORM\Column(type='string') private string $username; Going back to nested attributes, what I don’t like about “@[]” and “#[]” 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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php