rfc:iterable

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:iterable [2016/06/13 15:40] – Notes about object iteration trowskirfc:iterable [2018/08/07 01:40] (current) – Change status to: Implemented in PHP 7.1 carusogabriel
Line 3: Line 3:
   * Date: 2016-06-10   * Date: 2016-06-10
   * Author: Aaron Piotrowski <aaron@trowski.com>   * Author: Aaron Piotrowski <aaron@trowski.com>
-  * Status: Under Discussion+  * Status: Implemented in PHP 7.1
   * First Published at: http://wiki.php.net/rfc/iterable   * First Published at: http://wiki.php.net/rfc/iterable
  
Line 47: Line 47:
     yield 2;     yield 2;
     yield 3;     yield 3;
 +}
 +</code>
 +
 +Classes extending/implementing may broaden methods using ''array'' or ''Traversable'' as parameter types to ''iterable'' or narrow return types from ''iterable'' to ''array'' or ''Traversable''. This behavior is the same as that proposed for all union types in the [[union_types|Union Types RFC]].
 +
 +<code php>
 +interface Example {
 +    public function method(array $array): iterable;
 +}
 +
 +class ExampleImplementation implements Example {
 +    public function method(iterable $iterable): array {
 +        // Parameter broadened and return narrowed.
 +    }
 } }
 </code> </code>
Line 79: Line 93:
 ===== Voting ===== ===== Voting =====
 This proposal requires a 2/3 majority to be accepted. This proposal requires a 2/3 majority to be accepted.
 +
 +Voting began on 2016-06-24 at 6:00 pm GMT and ended on 2016-07-02 at 11:59 pm GMT
 +
 +<doodle title="Add iterable type to PHP 7.1" auth="trowski" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
 PR: [[https://github.com/php/php-src/pull/1941|#1941]] PR: [[https://github.com/php/php-src/pull/1941|#1941]]
rfc/iterable.txt · Last modified: 2018/08/07 01:40 by carusogabriel