rfc:final_class_const
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:final_class_const [2021/04/23 17:11] – kocsismate | rfc:final_class_const [2021/07/06 20:52] (current) – kocsismate | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Date: 2021-04-23 | * Date: 2021-04-23 | ||
* Author: Máté Kocsis < | * Author: Máté Kocsis < | ||
- | * Status: | + | * Status: |
* Implementation: | * Implementation: | ||
+ | * Target Version: PHP 8.1 | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 11: | Line 12: | ||
First of all, the engine can't optimize class constant references when late static binding is involved, so it has to pessimistically assume that '' | First of all, the engine can't optimize class constant references when late static binding is involved, so it has to pessimistically assume that '' | ||
- | What's more important is that one cannot make sure that a class constant value stays constant. Even if one always references them by using '' | + | What's more important is that class constants are not guaranteed to stay constant. Even if the declaring class always references them by using '' |
- | Another | + | A related |
<code php> | <code php> | ||
Line 29: | Line 30: | ||
</ | </ | ||
- | This leads to an interesting | + | This leads to a weird inconsistency. By introducing an intermediate class, overriding still becomes possible: |
<code php> | <code php> | ||
Line 52: | Line 53: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | The final modifier can be added to class constants. Doing so prevents a constant | + | The final modifier can be added to class constants. Doing so prevents |
<code php> | <code php> | ||
Line 88: | Line 89: | ||
===== Reflection ===== | ===== Reflection ===== | ||
- | A '' | + | A '' |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 96: | Line 97: | ||
===== Vote ===== | ===== Vote ===== | ||
- | Add support for final class constants? | + | Voting started on 2021-05-19 08:00 UTC and ends 2021-06-02 08:00 UTC. The vote requires 2/3 majority to be accepted. |
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
rfc/final_class_const.txt · Last modified: 2021/07/06 20:52 by kocsismate