rfc:mixed-typehint

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:mixed-typehint [2017/09/22 13:28] – external edit 127.0.0.1rfc:mixed-typehint [2017/12/19 03:03] – status update majkl
Line 3: Line 3:
   * Date: 2017-07-19   * Date: 2017-07-19
   * Author: Michael Moravec (php.net@majkl578.cz)   * Author: Michael Moravec (php.net@majkl578.cz)
-  * Status: Draft+  * Status: Under Discussion
   * First Published at: http://wiki.php.net/rfc/mixed-typehint   * First Published at: http://wiki.php.net/rfc/mixed-typehint
  
 ===== Introduction ===== ===== Introduction =====
-With the addition of scalar types in PHP 7, nullables in 7.1 and recently object in 7.2, it's now possible to explicitly declare accepted types for most of the parameters and return types. Unfortunately without mixed type it's still not possible to achieve a fully type hinted and consistent code.+With the addition of scalar types in PHP 7, nullables in 7.1 and recently object in 7.2, it's now possible to explicitly declare accepted types for most of the parameters and return types. Unfortunately without mixed type it's still not possible to achieve a fully type hinted and consistent code using simple types.
  
 ===== Proposal ===== ===== Proposal =====
-This RFC proposes to add the ''mixed'' type to be used for parameter and return types to explicitly declare desired type.+This RFC proposes to add the ''mixed'' type to be used for parameter and return types to explicitly declare desired type, instead of being forced to not declare anything.
  
 Primary motivation for having explicit mixed type is consistence and easier static analysis. Primary motivation for having explicit mixed type is consistence and easier static analysis.
-In PHP 7.2, mixed types are unfortunately the only type that could not be type hinted upon (and resource as well, but its future is unclear and usage rare). Having mixed type would allow a code with 100% type coverage in most cases.+In PHP 7.2, mixed types are unfortunately the only type that could not be type hinted upon (and resource as well, but its future is unclear). Having mixed type would allow a code with 100% type coverage in most cases.
  
-The behavior of the ''mixed'' type fully matches the behavior when nothing is specified for parameter or return type (thus being implicitly mixed), effectively being an alias.+The behavior of the ''mixed'' type fully matches the behavior when nothing is specified for parameter or return type (thus being implicitly mixed), effectively being an alias for previous behavior.
  
 ===== Nullability ===== ===== Nullability =====
Line 62: Line 62:
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
-None, ''mixed'' is already reserved since PHP 7.0.+None, ''mixed'' is already reserved word since PHP 7.0.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
-7.2 if RMs agree, otherwise 7.3+7.3
  
 ===== RFC Impact ===== ===== RFC Impact =====
Line 75: Line 75:
  
 ==== To Opcache ==== ==== To Opcache ====
-None.+Not analyzed.
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
rfc/mixed-typehint.txt · Last modified: 2020/07/22 09:03 by kocsismate