rfc:fallback-to-root-scope-deprecation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:fallback-to-root-scope-deprecation [2017/03/05 13:40] – wesnetmo | rfc:fallback-to-root-scope-deprecation [2018/02/03 12:30] – wesnetmo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC - Deprecation of fallback to root scope: ====== | + | ====== PHP RFC - Deprecation of fallback to root scope ====== |
* Version: 0.1 | * Version: 0.1 | ||
* Date: 2017-03-05 | * Date: 2017-03-05 | ||
- | * Author: Levi Morrison, | + | * Author: |
* Status: Under Discussion | * Status: Under Discussion | ||
* First Published at: https:// | * First Published at: https:// | ||
- | ===== Introduction: ===== | + | ===== Introduction ===== |
- | Fallback to root scope was implemented | + | Fallback to global |
- | **<1 Levi thinks this should be removed>** | + | <code php> |
- | + | namespace | |
- | It made possible to easily convert existing code to their namespaced equivalent by simply replacing '' | + | strlen(); |
- | + | // first tries to call \Bar\strlen() | |
- | While this helped the transition to namespaces a lot, it created several problems. **</1>** It forces PHP to constantly re-check what a symbol actually is every time it is accessed | + | // if not found, fallbacks |
+ | </ | ||
- | @TODO more reasoning? | + | This feature causes |
- | ===== Proposal: ===== | + | ===== Proposal ===== |
- | This RFC proposes to deprecate the fallback to root scope, by emitting a '' | + | This RFC proposes to deprecate the fallback to root scope, by emitting a deprecation notice, e.g.: |
< | < | ||
Line 28: | Line 29: | ||
</ | </ | ||
- | It also proposes, considered the entity of the change, that the " | + | It also proposes, considered the entity of the change, that the " |
- | ===== Impact to users, before and after the removal: ===== | + | In fact, if the feature |
- | + | ||
- | ==== PHPStorm: ==== | + | |
- | + | ||
- | PHPStorm | + | |
- | + | ||
- | Depending on a per-project setting, users will have either '' | + | |
- | + | ||
- | The PHPStorm' | + | |
- | + | ||
- | As such, **users will be able to avoid the '' | + | |
- | + | ||
- | ==== Roave' | + | |
- | + | ||
- | Another valuable tool is [[https:// | + | |
- | + | ||
- | ==== Fixing broken | + | |
- | + | ||
- | Since this feature will be removed in conjunction | + | |
<code php> | <code php> | ||
+ | // Fallback to global scope shim | ||
+ | // This code simply copies \strlen to \Current\NS\strlen | ||
register_autoloader( | register_autoloader( | ||
AUTOLOAD_FUNCTION | AUTOLOAD_CONST, | AUTOLOAD_FUNCTION | AUTOLOAD_CONST, | ||
Line 87: | Line 72: | ||
</ | </ | ||
- | This would provide a decent enough solution | + | However, if this RFC passes, authors should try to avoid the Notice by writing `\strlen()` or `use function {strlen, strpos};` in their code, which are **plenty of solutions |
+ | |||
+ | ===== Migration Tools ===== | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * More coming soon... | ||
- | ===== Backward Incompatible Changes: ===== | + | ===== Backward Incompatible Changes ===== |
None (the '' | None (the '' | ||
Line 95: | Line 87: | ||
===== Proposed PHP Version: ===== | ===== Proposed PHP Version: ===== | ||
- | 7.2 | + | 7.3 |
- | ===== Voting: ===== | + | ===== Voting ===== |
2/3 majority will be required. | 2/3 majority will be required. | ||
- | ===== References: ===== | + | ===== References ===== |
- | @TODO link discussion | + | - [[https:// |
rfc/fallback-to-root-scope-deprecation.txt · Last modified: 2018/02/03 16:26 by wesnetmo