rfc:mixed-typehint
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:mixed-typehint [2017/12/19 03:03] – status update majkl | rfc:mixed-typehint [2018/07/01 16:16] – Fix void* type carusogabriel | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Mixed typehint ====== | ====== PHP RFC: Mixed typehint ====== | ||
- | * Version: 1.0 | + | * Version: 1.1 |
* Date: 2017-07-19 | * Date: 2017-07-19 | ||
* Author: Michael Moravec (php.net@majkl578.cz) | * Author: Michael Moravec (php.net@majkl578.cz) | ||
Line 10: | Line 10: | ||
===== Proposal ===== | ===== Proposal ===== | ||
+ | |||
This RFC proposes to add the '' | This RFC proposes to add the '' | ||
Line 18: | Line 19: | ||
===== Nullability ===== | ===== Nullability ===== | ||
- | As the '' | + | |
+ | As the '' | ||
<code php> | <code php> | ||
- | function foo(): ?mixed {} | + | function foo() : ?mixed {} |
// Fatal error | // Fatal error | ||
</ | </ | ||
Line 29: | Line 31: | ||
No changes to variance needed. Exactly same rules as when no type is present apply. | No changes to variance needed. Exactly same rules as when no type is present apply. | ||
- | Since the '' | + | Since the '' |
<code php> | <code php> | ||
function foo($arg) { | function foo($arg) { | ||
Line 42: | Line 44: | ||
</ | </ | ||
- | Same applies | + | Same rules apply to inheritance, |
<code php> | <code php> | ||
class Foo { | class Foo { | ||
Line 54: | Line 56: | ||
} | } | ||
} | } | ||
- | class Baz extends | + | class Baz extends |
public function test(mixed $arg): mixed { | public function test(mixed $arg): mixed { | ||
return parent:: | return parent:: | ||
Line 60: | Line 62: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== Mixed vs. Void ===== | ||
+ | |||
+ | As of PHP 7.1, PHP has a special '' | ||
+ | |||
+ | In some other languages like C/C++ '' | ||
+ | This essentially matches the behavior of '' | ||
+ | |||
+ | As void is not a real type in PHP, it is not part of '' | ||
+ | Should there ever be a type that includes all types //and// '' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
+ | |||
None, '' | None, '' | ||
+ | Variance behavior is same as when no type is specified. | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
+ | |||
7.3 | 7.3 | ||
===== RFC Impact ===== | ===== RFC Impact ===== | ||
==== To SAPIs ==== | ==== To SAPIs ==== | ||
+ | |||
None. | None. | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
+ | |||
None. | None. | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
- | Not analyzed. | + | |
+ | Not analyzed, likely none (no changes to current language behavior). | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
+ | |||
No changes to type cast operators. | No changes to type cast operators. | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
+ | |||
Simple yes/no vote to either accept or reject addition of mixed type. | Simple yes/no vote to either accept or reject addition of mixed type. | ||
As this is a language change, 2/3 majority is required. | As this is a language change, 2/3 majority is required. | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
+ | |||
[[https:// | [[https:// | ||
rfc/mixed-typehint.txt · Last modified: 2020/07/22 09:03 by kocsismate