rfc:shorter_attribute_syntax

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:shorter_attribute_syntax [2020/06/16 16:11]
theodorejb Fix links
rfc:shorter_attribute_syntax [2020/08/12 15:56] (current)
theodorejb Update nested syntax for #[] - I think this was a relic of the idea to strip all leading hashes
Line 2: Line 2:
   * Date: 2020-06-03   * Date: 2020-06-03
   * Author: Theodore Brown <theodorejb@outlook.com>, Martin Schröder   * Author: Theodore Brown <theodorejb@outlook.com>, Martin Schröder
-  * Status: Under Discussion+  * Status: Implemented
   * Discussion: https://externals.io/message/110355   * Discussion: https://externals.io/message/110355
   * Target Version: PHP 8.0   * Target Version: PHP 8.0
-  * Implementation for ''@@''Based on https://github.com/kooldev/php-src/pull/2 (requires a single character to be changed in the lexer and a small grammar adjustment) +  * Implementation: https://github.com/php/php-src/pull/5796
-  * Implementation for ''#[]'': https://github.com/koolkode/php-src/pull/5+
  
 ===== Introduction ===== ===== Introduction =====
Line 165: Line 164:
 ===== Alternative #[] syntax ===== ===== Alternative #[] syntax =====
  
-An alternative to using ''@@Attr'' would be to borrow the ''#[attr]'' syntax from Rust. This would have the benefit of reusing the same syntax as another language, and it is also potentially forwards compatible for single-line attributes. E.g. the following code works with both PHP 7 and PHP 8 (the attribute is treated as a comment on PHP 7):+An alternative to using ''@@Attr'' would be to borrow the ''#[attr]'' syntax from Rust. This would have the benefit of reusing the same syntax as another language, and it is also potentially forwards compatible for single-line attributes. E.g. the following code could work with both PHP 7 and PHP 8 (the attribute is treated as a comment on PHP 7):
  
 <code php> <code php>
Line 199: Line 198:
     #[JoinTable(     #[JoinTable(
         "User_Group",         "User_Group",
-        #JoinColumn("User_id", "id"), +        #[JoinColumn("User_id", "id")]
-        #JoinColumn("Group_id", "id"),+        #[JoinColumn("Group_id", "id")],
     )]     )]
     private $groups;     private $groups;
Line 304: Line 303:
 ===== Community Poll ===== ===== Community Poll =====
  
-On June 10 there was a poll on Reddit to see which syntax the community prefers. [[https://www.reddit.com/r/PHP/comments/h06bra/community_poll_attribute_syntax/|12]]+On June 10-13 there was a poll on Reddit to see which syntax the community prefers. [[https://www.reddit.com/r/PHP/comments/h06bra/community_poll_attribute_syntax/|12]]
  
 ''@@'' was the most popular, with 436 votes. ''%%<<>>%%'' came in second place, with 240 votes. ''#[]'' came in third place, with 159 votes. ''@@'' was the most popular, with 436 votes. ''%%<<>>%%'' came in second place, with 240 votes. ''#[]'' came in third place, with 159 votes.
Line 311: Line 310:
 ===== Vote ===== ===== Vote =====
  
-Are you okay with re-voting on the attribute syntax for PHP 8.0, including the already accepted ''%%<<>>%%'' option? Yes/No+Voting started on 2020-06-17 and ended on 2020-07-01. 
 + 
 +==== Primary vote ==== 
 + 
 +<doodle title="Are you okay with re-voting on the attribute syntax for PHP 8.0?" auth="theodorejb" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle> 
 + 
 +==== Secondary vote ==== 
 + 
 +This is a ranked-choice poll (following [[https://en.wikipedia.org/wiki/Single_transferable_vote#Example|STV]]) between the ''@@'', ''#[]'', and ''%%<<>>%%'' syntax alternatives. You can vote **three** times, but make sure you select each syntax only once. 
 + 
 +=== First choice === 
 + 
 +<doodle title="Attribute syntax choice #1" auth="theodorejb" voteType="single" closed="true"> 
 +   * @@ 
 +   * #[] 
 +   * <<>> 
 +</doodle> 
 + 
 +=== Second choice === 
 + 
 +<doodle title="Attribute syntax choice #2" auth="theodorejb" voteType="single" closed="true"> 
 +   * @@ 
 +   * #[] 
 +   * <<>> 
 +</doodle> 
 + 
 +=== Third choice === 
 + 
 +<doodle title="Attribute syntax choice #3" auth="theodorejb" voteType="single" closed="true"> 
 +   * @@ 
 +   * #[] 
 +   * <<>> 
 +</doodle>
  
-Secondary vote: ranked-choice vote between ''@@'', ''#[]'', and ''%%<<>>%%'' syntax alternatives. 
  
 ===== References ===== ===== References =====
Line 319: Line 352:
   * Previous discussion about nested attributes: https://externals.io/message/108907#109623 and https://externals.io/message/108907#109688   * Previous discussion about nested attributes: https://externals.io/message/108907#109623 and https://externals.io/message/108907#109688
   * Previous comments in favor of ''@@'': https://externals.io/message/109713#109742   * Previous comments in favor of ''@@'': https://externals.io/message/109713#109742
 +
  
 ===== Changelog ===== ===== Changelog =====
rfc/shorter_attribute_syntax.1592323887.txt.gz · Last modified: 2020/06/16 16:11 by theodorejb