rfc:arrayof

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
Next revisionBoth sides next revision
rfc:arrayof [2014/01/15 21:36] – Added performance philsturfc:arrayof [2014/01/17 09:13] – fix typo tyrael
Line 21: Line 21:
 </code> </code>
  
-The square brackets allow type-hinting for an array where each value is of a specific type. This is handy when simply type-hinting with "array" is just not clear enough what the content should be. It improves readability and self-documentation of the signature, and avoids asking users to forech through the argument to calculate if each item is of the expected type.+The square brackets allow type-hinting for an array where each value is of a specific type. This is handy when simply type-hinting with "array" is just not clear enough what the content should be. It improves readability and self-documentation of the signature, and avoids asking users to foreach through the argument to calculate if each item is of the expected type.
  
 Default values can still be used: Default values can still be used:
Line 118: Line 118:
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
  
-This RFC has no effect on [[https://wiki.php.net/rfc/variadics|variadics]], or [[https://wiki.php.net/rfc/named_params|named parameters]]. It does not alter other type-hinting rules in regards to what can be hinted against (callable, array, classes, interface, traits, etc) and does not attempt to type-hint against scalar values.+This RFC has no effect on [[https://wiki.php.net/rfc/variadics|variadics]], or [[https://wiki.php.net/rfc/named_params|named parameters]]. It does not alter other type-hinting rules in regards to what can be hinted against (callable, array, classes, interface, traits, etc) and does not attempt to type-hint against scalar values. This is being taken care of in [[https://wiki.php.net/rfc/scalar_type_hinting_with_cast|Scalar Type Hinting with Case]]
  
 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.
rfc/arrayof.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1