rfc:iterator_xyz_accept_array
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:iterator_xyz_accept_array [2022/06/21 14:10] – created timwolla | rfc:iterator_xyz_accept_array [2022/07/19 14:47] (current) – Implemented. timwolla | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2022-06-21 | * Date: 2022-06-21 | ||
* Author: Tim Düsterhus, duesterhus@woltlab.com | * Author: Tim Düsterhus, duesterhus@woltlab.com | ||
- | * Status: | + | * Status: |
+ | * Target Version: PHP 8.2 | ||
+ | * Implementation: | ||
* First Published at: http:// | * First Published at: http:// | ||
Line 9: | Line 11: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | PHP's iterator_*() family currently only accept < | + | PHP' |
- | Specifically this concerns the < | + | Specifically this concerns the < |
+ | |||
+ | As an example: Allowing < | ||
+ | |||
+ | < | ||
+ | function before(iterable $foo) { | ||
+ | if (!is_array($foo)) { | ||
+ | $foo = iterator_to_array($foo); | ||
+ | } | ||
+ | |||
+ | return array_map(strlen(...), | ||
+ | } | ||
+ | function after(iterable $foo) { | ||
+ | $foo = iterator_to_array($foo); | ||
+ | |||
+ | return array_map(strlen(...), | ||
+ | } | ||
+ | </ | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | The < | + | The < |
+ | |||
+ | Specifically if this RFC is accepted the following shall hold: | ||
+ | |||
+ | ==== iterator_to_array ==== | ||
+ | |||
+ | < | ||
+ | iterator_to_array($array, | ||
+ | iterator_to_array($array, | ||
+ | </ | ||
+ | |||
+ | ==== iterator_count ==== | ||
+ | |||
+ | < | ||
+ | iterator_count($array) == count($array) | ||
+ | </ | ||
+ | |||
+ | ==== iterator_apply ==== | ||
+ | |||
+ | This function is **not** part of this proposal, because it is non-obvious how to define the behavior for < | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 53: | Line 91: | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | Anything that isn't < | + | Anything that isn't < |
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 61: | Line 99: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Each vote requires a 2/3 majority.. | + | Each vote requires a 2/3 majority. |
+ | |||
+ | Voting opened 2022-07-05 14:30 UTC and closes on 2022-07-19 14:45 UTC. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
- | * Vote 1: Change the type of <php> | + | <doodle title=" |
- | * Vote 2: Change the type of <php>iterator_count()</ | + | |
- | * Vote 3: Change the type of < | + | * No |
+ | </doodle> | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | PoC implementation to < | + | https:// |
===== Implementation ===== | ===== Implementation ===== | ||
- | n/a | + | https:// |
===== References ===== | ===== References ===== | ||
Line 79: | Line 127: | ||
* Pre-RFC discussion: https:// | * Pre-RFC discussion: https:// | ||
* PoC implementation: | * PoC implementation: | ||
- | * Similar previous RFC that proposed adding **new** functions: https:// | + | * Similar previous RFC that proposed adding **new** functions |
+ | * Stack Overflow asking for < | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
none | none |
rfc/iterator_xyz_accept_array.txt · Last modified: 2022/07/19 14:47 by timwolla