rfc:array_change_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:array_change_keys [2016/05/31 01:32] – Update pros & cons colinodellrfc:array_change_keys [2018/11/27 23:34] (current) – Withdrawing the RFC colinodell
Line 3: Line 3:
   * Date: 2016-05-29   * Date: 2016-05-29
   * Authors: Colin O'Dell <colinodell@gmail.com>, Jeremy Mikola <jmikola@gmail.com>   * Authors: Colin O'Dell <colinodell@gmail.com>, Jeremy Mikola <jmikola@gmail.com>
-  * Status: Discussion+  * Status: Withdrawn
   * First Published at: http://wiki.php.net/rfc/array_change_keys   * First Published at: http://wiki.php.net/rfc/array_change_keys
  
Line 113: Line 113:
 ==== Function Name ==== ==== Function Name ====
  
-PHP already has an ''array_change_key_case()'' function, so sharing a common root name (''array_change_key'') seems like a logic choice.+PHP already has an ''array_change_key_case()'' function, so sharing a common root name (''array_change_key'') seems like a logical choice.
  
-Other function which deal with multiple keys (like ''array_keys'' and ''array_fill_keys'') are pluralized, so we're using that same convention here.+Other functions which deal with multiple keys (like ''array_keys'' and ''array_fill_keys'') are pluralized, so we're using that same convention here.
  
 ===== Discussion ===== ===== Discussion =====
Line 134: Line 134:
  
 Using this function makes it immediately obvious to other developers that an array is being re-keyed. Using this function makes it immediately obvious to other developers that an array is being re-keyed.
 +
 +=== Matches Existing Behavior ===
 +
 +The "edge cases" mentioned above (returning invalid types or duplicate keys) matches existing behavior in PHP that developers already understand and expect.  No new edge cases or quirks are being introduced with this RFC.
  
 === Faster Execution Than array_combine() === === Faster Execution Than array_combine() ===
Line 184: Line 188:
 ===== Future Scope ===== ===== Future Scope =====
  
-Returning ''__toString()''able objects from the callback is not supported by this RFC.  This matches the behavior of other functions like ''array_flip()'' and ''array_fill_keys()'' If such functionality is desired, a separate RFC could be created to add this functionality to all similar functions.+Other ''array_'' functions do not support certain features like using ''__toString()'' for keys or supporting ''Traversable'' objects like iterators, so support for them is not being proposed here either.  If such functionality is desired, a separate RFC could be created to add this functionality to all similar functions.
  
-===== Proposed Voting Choices =====+===== Voting =====
 Because this is not a language change, a 50%+1 vote will be required to add this new function. Because this is not a language change, a 50%+1 vote will be required to add this new function.
  
Line 196: Line 200:
 ===== References ===== ===== References =====
 Links to external references, discussions or RFCs Links to external references, discussions or RFCs
 +
 +Mailing list discussion: [[https://marc.info/?l=php-internals&m=146452769326964&w=2]]
 +
 +Reddit discussion: [[https://www.reddit.com/r/PHP/comments/4ll1hg/rfc_array_change_keys/]]
rfc/array_change_keys.1464658366.txt.gz · Last modified: 2017/09/22 13:28 (external edit)