rfc:arrayof

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
rfc:arrayof [2014/01/17 11:43]
krakjoe
rfc:arrayof [2017/09/22 13:28] (current)
Line 1: Line 1:
  
 ====== PHP RFC: Array Of ====== ====== PHP RFC: Array Of ======
-  * Version: 0.1.1+  * Version: 0.2.0
   * Date: 2014-01-15   * Date: 2014-01-15
   * Author: Joe Watkins, krakjoe@php.net & Phil Sturgeon philstu@php.net   * Author: Joe Watkins, krakjoe@php.net & Phil Sturgeon philstu@php.net
-  * Status: Under Discussion+  * Status: Declined
   * First Published at: http://wiki.php.net/rfc/arrayof   * First Published at: http://wiki.php.net/rfc/arrayof
  
Line 122: Line 122:
 This also does not attempt to allow Traversable or other objects implementing interfaces to be considered an "array", to match current behavior with hinting for an array. This also does not attempt to allow Traversable or other objects implementing interfaces to be considered an "array", to match current behavior with hinting for an array.
  
-===== Open Questions =====+===== Closed Questions =====
  
-1. The RFC is currently //effectively// the same as the code below:+1. Should multi-dimensional hints be allowed? 
 + 
 +<code php> 
 +function test(Foo[][] $files = null) {} 
 +</code> 
 + 
 +The general consensus seemed to be that instead of using "function (ChessPieces[][])" a better solution would probably to simply use "function (Black[] $pieces, White[] $pieces)" instead. 
 + 
 + 
 +2. RFC suggested syntax, or Hack Generics syntax? 
 + 
 +With this features close proximity to the "generics" feature found in other languages - including Java, C# and Hack - the Hack syntax was suggested to replace the syntax in this RFC, which would be the first half of a larger effort in a later version to introduce full-generics. A survey was held to see if people were interested in going down the route of generics and the answer was mostly "Yes, but we want this Array Of too"
 + 
 +http://grokbase.com/p/php/php-internals/141rva4cf7/php-dev-vote-array-of-v-generics 
 + 
 +Java has both features, with their own syntax. This means there is no reason for us to hold off implementing with the existing syntax and looking into adding generics as well, at a later date.  
 + 
 +If people want to change the syntax of this feature more in line with Hack generics syntax then simply vote no, and we can revisit the issue. 
 + 
 +3. The RFC is currently //effectively// the same as the code below:
  
 <code php> <code php>
Line 148: Line 167:
 Logic here would dictate that if you ask for a bag of spanners, you get a bag of spanners, not a bag with a few spanners and maybe a few  "I owe you one spanner" notes. Logic here would dictate that if you ask for a bag of spanners, you get a bag of spanners, not a bag with a few spanners and maybe a few  "I owe you one spanner" notes.
  
-2. Should multi-dimensional hints be allowed? +Multiple people suggested that by default allowing nulls would make this feature useless, and that syntax could be added for the alternative. This syntax can be addressed in a later RFC but could be as simple as function (Foo[]$foos). Undecided at this point.
- +
-<code php> +
-function test(Foo[][] $files = null) {} +
-</code> +
- +
-This suggests that array(array(new Foo)) is an acceptable value. I am not sure how useful that isas you should probably calm down on your nested array structure a little bit and maybe require an object, or split it into multiple parameters. +
- +
-One example provided has been "function (ChessPieces[][])". This would probably be better off as "function (Black[] $pieces, White[] $pieces)".+
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 165: Line 176:
  
 PHP 5.6 PHP 5.6
 +
 +===== Vote =====
 +
 +VOTE: 2014/02/28 - 2014/03/07
 +
 +<doodle title="Array Of Type Hinting" auth="philstu" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
  
 ===== Implementation ===== ===== Implementation =====
Line 178: Line 199:
 ===== References ===== ===== References =====
  
 +[[http://grokbase.com/t/php/php-internals/141f1kzdm8/introducing-array-of-rfc|ML Discussion]] 
 +[[http://grokbase.com/p/php/php-internals/141raagbec/php-dev-vote-array-of-v-generics|Array Of v Generics survey]]
rfc/arrayof.1389959014.txt.gz · Last modified: 2017/09/22 13:28 (external edit)