rfc:on_demand_name_mangling
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:on_demand_name_mangling [2016/01/09 02:13] – Removed deprecation message in favor of documentation changes bishop | rfc:on_demand_name_mangling [2019/07/16 12:25] (current) – Settled on formal polyfill name, php_mangle_superglobal bishop | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: On-demand Name Mangling ====== | ====== PHP RFC: On-demand Name Mangling ====== | ||
- | * Version: 1.3 | + | * Version: 1.4 |
* Created Date: 2016-01-01 | * Created Date: 2016-01-01 | ||
- | * Updated Date: 2016-01-08 | + | * Updated Date: 2019-07-16 |
- | * Author: Bishop Bettini, bishop@php.net | + | * Author: Bishop Bettini |
* Status: Under Discussion | * Status: Under Discussion | ||
* First Published at: http:// | * First Published at: http:// | ||
Line 62: | Line 62: | ||
<?php | <?php | ||
print_r(get_defined_vars()); | print_r(get_defined_vars()); | ||
- | mangle_superglobals(); | + | php_mangle_superglobals(); |
print_r(get_defined_vars()); | print_r(get_defined_vars()); | ||
?> | ?> | ||
Line 81: | Line 81: | ||
[_GET] => Array | [_GET] => Array | ||
( | ( | ||
- | [a.b] => dot | ||
[a_b] => bracket | [a_b] => bracket | ||
[a$b] => dollar | [a$b] => dollar | ||
- | [a b] => space | ||
- | [a[b] => bracket | ||
) | ) | ||
) | ) | ||
</ | </ | ||
- | In this new implementation, | + | In this new implementation, |
- | In the example above, an '' | + | In the example above, an '' |
Importantly, | Importantly, | ||
Line 106: | Line 103: | ||
This RFC proposes to remove automatic name mangling, with backward compatibility maintained through a userspace polyfill function that mangles super-globals on-demand: | This RFC proposes to remove automatic name mangling, with backward compatibility maintained through a userspace polyfill function that mangles super-globals on-demand: | ||
- | * Next minor release (currently 7.1): | + | * Upon acceptance: |
* Update documentation that name mangling is deprecated and will be removed in 8.0 | * Update documentation that name mangling is deprecated and will be removed in 8.0 | ||
- | * Between RFC acceptance and the next major release: | + | |
- | | + | |
* Polyfill shall be available via composer (but not PEAR) | * Polyfill shall be available via composer (but not PEAR) | ||
* Next major release (currently 8.0): | * Next major release (currently 8.0): | ||
- | * Remove all name mangling code in super-global | + | * Remove all name mangling code in super-global |
==== Discussion ==== | ==== Discussion ==== | ||
Line 159: | Line 155: | ||
<code php> | <code php> | ||
- | function | + | function |
$name = preg_replace('/ | $name = preg_replace('/ | ||
return preg_replace('/ | return preg_replace('/ | ||
} | } | ||
- | function | + | function |
if (version_compare(PHP_VERSION, | if (version_compare(PHP_VERSION, | ||
return; | return; | ||
} | } | ||
foreach ($_ENV as $var => &$val) { | foreach ($_ENV as $var => &$val) { | ||
- | $mangled = mangle_name($var); | + | $mangled = php_mangle_name($var); |
if ($mangled !== $var) { | if ($mangled !== $var) { | ||
$_ENV[$mangled] =& $val; | $_ENV[$mangled] =& $val; | ||
Line 186: | Line 182: | ||
require __DIR__ . '/ | require __DIR__ . '/ | ||
- | mangle_superglobals(); | + | php_mangle_superglobals(); |
// ... | // ... | ||
Line 192: | Line 188: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | PHP 7.1 (for notice of impending BC break) and PHP 8.0 (for actual implementation and corresponding BC break). | + | PHP 8.0. |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
Line 211: | Line 207: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | None so far. | + | None. |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | A simple yes/no voting option with a 2/3 majority required. | + | A simple yes/no voting option with a 2/3 majority required: " |
===== Patches and Tests ===== | ===== Patches and Tests ===== |
rfc/on_demand_name_mangling.1452305596.txt.gz · Last modified: 2017/09/22 13:28 (external edit)