rfc:never_for_parameter_types
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision |
rfc:never_for_parameter_types [2021/08/15 09:36] – s/edit/blob/ derick | rfc:never_for_parameter_types [2021/08/24 11:53] (current) – Withdrawing jordanrl |
---|
* Date: 2021-08-14 | * Date: 2021-08-14 |
* Author: Jordan LeDoux, jordan.ledoux@gmail.com | * Author: Jordan LeDoux, jordan.ledoux@gmail.com |
* Status: In Discussion | * Status: Withdrawn |
* First Published at: http://wiki.php.net/rfc/never_for_parameter_types | * First Published at: http://wiki.php.net/rfc/never_for_parameter_types |
| |
===== Introduction ===== | ===== Introduction ===== |
Arguments in PHP are contravariant to preserve Liskov substitution. This means that if class B extends class A, then redefines a function call, the entire type of that argument from class A must be present in the type of the argument in class B: | Parameters in PHP are contravariant to preserve Liskov substitution. This means that if class B extends class A, then redefines a function call, the entire type of that parameter from class A must be present in the type of the parameter in class B: |
| |
<code php> | <code php> |
</code> | </code> |
| |
Thus, the more specific a type is for an argument in a base class, the more broad it can be in an extending class with the requirement that it must also include the type from the base class. | Thus, the more specific a type is for an parameter in a base class, the more broad it can be in an extending class with the requirement that it must also include the type from the base class. |
| |
Since ''never'' is a bottom type within the PHP engine, all other types contain it. This RFC proposes allowing ''never'' as a valid argument type for functions. | Since ''never'' is a bottom type within the PHP engine, all other types contain it. This RFC proposes allowing ''never'' as a valid parameter type for functions. |
| |
===== Use Cases ===== | ===== Use Cases ===== |
rfc/never_for_parameter_types.1629020161.txt.gz · Last modified: 2021/08/15 09:36 by derick