rfc:allow-constant-override-consistently

Differences

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

Link to this comparison view

Next revisionBoth sides next revision
rfc:allow-constant-override-consistently [2018/04/11 02:26] – created wesnetmorfc:allow-constant-override-consistently [2018/04/11 02:34] wesnetmo
Line 1: Line 1:
-====== PHP RFC - Allow constant override consistently ======+====== PHP RFC - Consistent class-constant override ======
  
   * Version: 0.0.1   * Version: 0.0.1
   * Date: 2018-04-11   * Date: 2018-04-11
-  * Author: WesNetmo+  * Author: Pedro Magalhães, WesNetmo
   * Status: Under Discussion   * Status: Under Discussion
   * First Published at: https://wiki.php.net/rfc/allow-constant-override-consistently   * First Published at: https://wiki.php.net/rfc/allow-constant-override-consistently
Line 9: Line 9:
 ===== Introduction ===== ===== Introduction =====
  
-Currently, a class constant can be overridden in inheritors, but the same cannot be achieved when interfaces are involved.+Currently, a class constant can be overridden in inheritors, but it's disallowed in interfaces.
  
 <code php> <code php>
Line 20: Line 20:
 interface B2 extends A2 { const X = 2; } interface B2 extends A2 { const X = 2; }
  
 +// This doesn't work too:
 interface A3            { const X = 1; } interface A3            { const X = 1; }
 class B3 implements A3  { const X = 2; } class B3 implements A3  { const X = 2; }
Line 27: Line 28:
  
 <code php> <code php>
 +// This works:
 interface A3                    { const X = 1; } interface A3                    { const X = 1; }
 abstract class B3 implements A3 { } // Can't override here abstract class B3 implements A3 { } // Can't override here
Line 34: Line 36:
 ===== Proposal ===== ===== Proposal =====
  
-This RFC proposes to normalize the behavior so that constant override is allowed everywhere. This is not an invite at reckless overriding but simply a matter of consistency. Class constants are constants only within the class they are defined in; inheritors inherit them by default but the user can optionally override them if desired.+This RFC proposes to normalize the behavior so that constant override is allowed everywhere. This is not an invite at reckless overriding but simply a matter of consistency. Class constants are **constants only within the class they are defined in**child classes inherit them by default but the user can optionally override them if desired.
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 50: Line 52:
 ===== References ===== ===== References =====
  
-- [[https://externals.io/message/101823|Discussion on externals]]+- [[...........|Discussion on externals]]
rfc/allow-constant-override-consistently.txt · Last modified: 2018/04/14 04:56 by wesnetmo