rfc:constants_in_traits

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:constants_in_traits [2022/07/04 19:54] – fix example sjirfc:constants_in_traits [2022/07/19 22:00] – close the vote and move the status to accepted sji
Line 1: Line 1:
 ====== PHP RFC: Constants in Traits ====== ====== PHP RFC: Constants in Traits ======
-  * Version: 0.2+  * Version: 0.2.1
   * Date: 2022-06-21   * Date: 2022-06-21
   * Author: Shinji Igarashi<sji@sj-i.dev>, Stephen Reay<stephen@koalephant.com>   * Author: Shinji Igarashi<sji@sj-i.dev>, Stephen Reay<stephen@koalephant.com>
-  * Status: Under Discussion+  * Status: Accepted
   * Implementation: https://github.com/php/php-src/pull/8888   * Implementation: https://github.com/php/php-src/pull/8888
   * First Published at: http://wiki.php.net/rfc/constants_in_traits   * First Published at: http://wiki.php.net/rfc/constants_in_traits
Line 40: Line 40:
  
 <code php> <code php>
-intertface FooInterface {+interface FooInterface {
     public const FLAG_1 = 1;     public const FLAG_1 = 1;
     public function doFoo(int $flags): void;     public function doFoo(int $flags): void;
Line 222: Line 222:
         CONSTANT as private;         CONSTANT as private;
     }     }
 +}
 +</code>
 +
 +==== Can be used in Enum ====
 +Enumerations can use traits having constants, which behave as if the constants were defined within the enumeration.
 +
 +<code php>
 +trait T {
 +    private const CONSTANT = 42;
 +}
 +
 +// OK
 +enum E: int {
 +    use T;
 +
 +    case CaseA = self::CONSTANT;
 } }
 </code> </code>
Line 331: Line 347:
  
 ==== Rust ==== ==== Rust ====
-Rust has associated constants. Asociated constants are constants associated with a type. If multiple definitions of the same name conflict, they must be disambiguated on reference using qualified paths [[https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants|[17]]][[https://doc.rust-lang.org/reference/paths.html#qualified-paths|[18]]].+Rust has associated constants. Associated constants are constants associated with a type. If multiple definitions of the same name conflict, they must be disambiguated on reference using qualified paths [[https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants|[17]]][[https://doc.rust-lang.org/reference/paths.html#qualified-paths|[18]]].
  
 ==== C++ ==== ==== C++ ====
Line 340: Line 356:
  
  
-===== Proposed Voting Choices ===== +===== Vote ===== 
-A 2/3 majority is needed for this RFC to pass. Voting will start on 5. July 2022 and end on 19. July 2022+A 2/3 majority is needed for this RFC to pass. Voting started on 5. July 2022 and end on 19. July 2022 
 + 
 +<doodle title="Allow constants in traits as proposed?" auth="sji" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
  
rfc/constants_in_traits.txt · Last modified: 2022/08/04 19:17 by sji