rfc:shorter_attribute_syntax_change

PHP RFC: Shorter Attribute Syntax Change

Introduction

Based on the expressions of concern over using @@ for Shorter Attribute Syntax RFC https://wiki.php.net/rfc/shorter_attribute_syntax, I propose to use #[], @[], or the original << … >> instead. Please keep in mind that we want the best syntax, and not necessarily the best looking syntax.

The main concern is that @@ has no ending symbol and it's inconsistent with the language that it would be the only declaration or statement in the whole language that has no ending termination symbol.

Proposal

Pick the best syntax from the following options, taking into account the different pros and cons:

Syntax @@Attr #[Attr] @[Attr] <<Attr>>
Number of required Characters 2 3 3 4
Has End Delimiter No Yes Yes Yes
Allows Grouping (Accepted in previous RFC) No Yes Yes Yes
Forward Compatibilty in PHP 7 No Yes No No
Breaks BC of valid PHP 7 code Yes Yes Yes No
Used by other language No Yes No Yes
Familiar with Docblock Usage Yes No No No
Difficulties with Userland Parsers Yes Yes Yes No
Target 8.0 8.0 8.0 8.0
Patch - patch

Proposed PHP Version(s)

PHP 8.0

Proposed Voting Choices

An STV vote among all the qualifying syntaxes, running from August 10th, 00:00 UTC to August 23, 24:00 UTC.

Implementation

After the project is implemented, this section should contain

  • the version(s) it was merged into
  • a link to the git commit(s)
  • a link to the PHP manual entry for the feature
  • a link to the language specification section (if any)

References

Links to external references, discussions or RFCs

rfc/shorter_attribute_syntax_change.txt · Last modified: 2020/08/04 16:27 by theodorejb