rfc:foreach-non-scalar-keys

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:foreach-non-scalar-keys [2013/02/27 19:28] – start vote nikicrfc:foreach-non-scalar-keys [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 3: Line 3:
   * Date: 2013-01-28   * Date: 2013-01-28
   * Authors: Levi Morrison <levim@php.net>, Nikita Popov <nikic@php.net>   * Authors: Levi Morrison <levim@php.net>, Nikita Popov <nikic@php.net>
-  * Status: Voting +  * Status: Implemented in PHP 5.5 ([[https://github.com/php/php-src/commit/fcc6611de9054327441786e52444b5f8eecdd525|commit]])
-  * Target version: PHP 5.5+
  
 ===== Current situation ===== ===== Current situation =====
Line 60: Line 59:
 int (*get_current_key)(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC); int (*get_current_key)(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
 // Is replaced with this entry: // Is replaced with this entry:
-zval *(*get_current_key)(zend_object_iterator *iter TSRMLS_DC);+void (*get_current_key)(zend_object_iterator *iter, zval *key TSRMLS_DC);
 </code> </code>
  
-The handler will return a ''zval*'' with already increased refcount. The ''zval*'' may not be ''NULL'', unless an exception was thrown. +The handler has to write into the passed ''zval*'' using one of the ''ZVAL_*'' macros.
- +
-The signature can use ''zval*'' instead of ''zval**'' because by-ref modification of keys is not possible. The refcount is increased in the handler (instead of the VM) as that turned out to be the more convenient method for this use case.+
  
 ===== iterator_to_array() ===== ===== iterator_to_array() =====
Line 91: Line 88:
 ===== Patch ===== ===== Patch =====
  
-A preliminary patch implementing the above proposal can be found here: https://github.com/php/php-src/pull/278+The patch for this change can be found here: https://github.com/php/php-src/commit/fcc6611de9054327441786e52444b5f8eecdd525
  
 The change itself is rather small, but there are quite a few extensions that require minor adjustments to use the new API. The change itself is rather small, but there are quite a few extensions that require minor adjustments to use the new API.
Line 99: Line 96:
 Voting ends on March 6th. A 50% + 1 majority is required. This RFC targets PHP 5.5. Voting ends on March 6th. A 50% + 1 majority is required. This RFC targets PHP 5.5.
  
-<doodle title="Remove type-restrictions on foreach keys?" auth="user"> +<doodle title="Remove type-restrictions on foreach keys?" auth="nikic" voteType="single" closed="true"> 
- * Yes +   * Yes 
- * No+   * No
 </doodle> </doodle>
rfc/foreach-non-scalar-keys.1361993312.txt.gz · Last modified: 2017/09/22 13:28 (external edit)