rfc:typehint_array_desctructuring

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
Last revisionBoth sides next revision
rfc:typehint_array_desctructuring [2020/04/16 10:00] wol-softrfc:typehint_array_desctructuring [2020/04/16 11:43] wol-soft
Line 19: Line 19:
  
 ===== Proposal ===== ===== Proposal =====
-This proposal adds a new syntax to add type hints to array destructuring expressions. The type hints behave identically to the type hints processed for function calls (compare https://wiki.php.net/rfc/scalar_type_hints_v5). This includes a controllability of the behaviour using the strict_types directive:+This proposal adds a new syntax to add type hints to array destructuring expressions. The type hints behave identically to the type hints processed for function calls (compare https://wiki.php.net/rfc/scalar_type_hints_v5). This includes a controllability of the behaviour using the strict_types directive. Type checks will be executed during the assignment of the variables when resolving the array destructuring expression. The variables will **not** keep any information concerning the check (they will not behave like typed variables afterwards, just like type checks in method signatures).
  
 <code php> <code php>
Line 69: Line 69:
     // ...     // ...
 } }
 +</code>
 +
 +The for PHP 8.0 accepted union types (https://wiki.php.net/rfc/union_types_v2) will also be allowed:
 +
 +<code php>
 +[int|float $number, string $description] = [1.5, "One point five"]
 </code> </code>
  
rfc/typehint_array_desctructuring.txt · Last modified: 2020/04/16 13:56 by wol-soft