rfc:on_demand_name_mangling

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:on_demand_name_mangling [2017/09/22 13:28] – external edit 127.0.0.1rfc: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 Bettinibishop@php.net+  * Author: Bishop Bettini <bishop@php.net>
   * Status: Under Discussion   * Status: Under Discussion
   * First Published at: http://wiki.php.net/rfc/on_demand_name_mangling   * First Published at: http://wiki.php.net/rfc/on_demand_name_mangling
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 
         )         )
 ) )
 </code> </code>
  
-In this new implementation, the engine no longer mangles marshaled superglobals at startup.  Instead, the //ability// to mangle names has moved to an optional, userland-provided polyfill function ''mangle_superglobals()''.+In this new implementation, the engine no longer mangles marshaled superglobals at startup.  Instead, the //ability// to mangle names has moved to an optional, userland-provided polyfill function ''php_mangle_superglobals()''.
  
-In the example above, an ''a_b'' key was externally supplied. The call to ''mangle_superglobals'' clobbered the original value of ''a_b'' with the value of the //last// seen mangle-equivalent key (''a[b'').+In the example above, an ''a_b'' key was externally supplied. The call to ''php_mangle_superglobals'' clobbered the original value of ''a_b'' with the value of the //last// seen mangle-equivalent key (''a[b'').
  
 Importantly, the user made this mangling happen: the engine did not do it automatically. Importantly, the user made this mangling happen: the engine did not do it automatically.
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: +    * Release a userland polyfill that implements the historic mangling behavior
-    * Release a userland polyfill that implements ''mangle_superglobals''+
     * 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 marshalling functions+    * Remove all name mangling code in super-global marshaling functions
  
 ==== Discussion ==== ==== Discussion ====
Line 159: Line 155:
  
 <code php> <code php>
-function mangle_name($name) {+function php_mangle_name($name) {
     $name = preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '_', $name);     $name = preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '_', $name);
     return preg_replace('/^[0-9]/', '_', $name);     return preg_replace('/^[0-9]/', '_', $name);
 } }
-function mangle_superglobals() {+function php_mangle_superglobals() {
     if (version_compare(PHP_VERSION, '8.0.0', '<')) {     if (version_compare(PHP_VERSION, '8.0.0', '<')) {
         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__ . '/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
  
-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: "Remove name mangling in PHP 8.0?"
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
rfc/on_demand_name_mangling.1506086901.txt.gz · Last modified: 2017/09/22 13:28 by 127.0.0.1