rfc:case_insensitive_constant_deprecation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:case_insensitive_constant_deprecation [2018/06/24 11:07] – Move to under discussion nikic | rfc:case_insensitive_constant_deprecation [2018/07/16 16:56] – Accepted nikic | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Target PHP version: PHP 7.3 | * Target PHP version: PHP 7.3 | ||
* Implementation: | * Implementation: | ||
- | * Status: | + | |
+ | | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 20: | Line 21: | ||
* In PHP 7.3: Deprecate calling '' | * In PHP 7.3: Deprecate calling '' | ||
- | * In PHP 7.3: Deprecate accessing a case-insensitive constant with a casing that differs from the declaration-site. | + | * In PHP 7.3: Deprecate accessing a case-insensitive constant with a casing that differs from the declaration-site. The constants '' |
* In PHP 8.0: Remove the possibility of declaring case-insensitive constants. | * In PHP 8.0: Remove the possibility of declaring case-insensitive constants. | ||
- | * The '' | + | * In PHP 8.0: '' |
===== Motivation ===== | ===== Motivation ===== | ||
Line 70: | Line 71: | ||
Not only was the declaration of a clashing constant permitted, but it effectively changed the value of the '' | Not only was the declaration of a clashing constant permitted, but it effectively changed the value of the '' | ||
- | This problem is further confounded by assumptions (such as: constants are constant) in the PHP engine and opcache optimizations, | + | This problem is further confounded by assumptions (such as: constants are constant) in the PHP engine and opcache optimizations, |
This is an issue that can in principle be resolved, however it would come with significant additional implementation complexity and a hit to performance and memory usage. At the least, it would require storing lower-cased variants of all constants and checking against them on new constant declarations. | This is an issue that can in principle be resolved, however it would come with significant additional implementation complexity and a hit to performance and memory usage. At the least, it would require storing lower-cased variants of all constants and checking against them on new constant declarations. | ||
- | ==== Implementation overhead ==== | + | ==== Implementation |
Support for case-insensitive constants makes the implementation more complex and slower. Constant lookups are implemented by first looking up the constant name directly, and then looking up a lowercased variant. | Support for case-insensitive constants makes the implementation more complex and slower. Constant lookups are implemented by first looking up the constant name directly, and then looking up a lowercased variant. | ||
- | A particularly extreme case are access to unqualified constants inside namespaces. For example, if constant '' | + | A particularly extreme case are access to unqualified constants inside namespaces. For example, if constant '' |
| | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 100: | Line 101: | ||
==== Handling of true, false and null ==== | ==== Handling of true, false and null ==== | ||
- | '' | + | '' |
- | There are at least two ways in which we can handle | + | '' |
- | The first is to retain them as special | + | This RFC proposes |
- | The second is to turn them into reserved keywords. This would be the more principled approach, but would also be a slightly larger BC break. It particular it would mean that '' | + | * As '' |
+ | * '' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 112: | Line 114: | ||
Additional deprecation warnings are thrown in PHP 7.3. Case-insensitive constants are removed in PHP 8. | Additional deprecation warnings are thrown in PHP 7.3. Case-insensitive constants are removed in PHP 8. | ||
- | Depending on the choice regarding | + | '' |
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
Magic constants are not affected. These are already reserved keywords (always case-insensitive), | Magic constants are not affected. These are already reserved keywords (always case-insensitive), | ||
+ | |||
+ | Class constants are not affected, they are already case-sensitive. | ||
===== Vote ===== | ===== Vote ===== | ||
- | Since this is a language change, a 2/3 majority is required. | + | Since this is a language change, a 2/3 majority is required. |
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ |
rfc/case_insensitive_constant_deprecation.txt · Last modified: 2018/07/16 17:18 by nikic