rfc:make_ctor_ret_void
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:make_ctor_ret_void [2020/06/17 22:06] – updated RFC moliata | rfc:make_ctor_ret_void [2020/07/05 14:03] – updated RFC moliata | ||
---|---|---|---|
Line 40: | Line 40: | ||
==== Proposal ==== | ==== Proposal ==== | ||
This RFC proposes: | This RFC proposes: | ||
- | * to deprecate the ability of returning | + | * to deprecate the ability of returning values from constructors and destructors in PHP 8.0. |
- | * to treat both contructors | + | * to treat both constructors |
* to allow explicit '' | * to allow explicit '' | ||
A deprecation warning would be generated: | A deprecation warning would be generated: | ||
- | * for any constructor or destructor that returns a non-'' | + | * for any constructor or destructor that returns a value in PHP 8.0 |
+ | |||
+ | Note: if there is an explicit | ||
A fatal error would be generated: | A fatal error would be generated: | ||
- | * for any constructor or destructor that returns a non-'' | + | * for any constructor or destructor that returns a value in PHP 9.0. |
* for any constructor or destructor that has an explicit return type other than '' | * for any constructor or destructor that has an explicit return type other than '' | ||
Line 59: | Line 61: | ||
} | } | ||
- | // this is illegal | + | // this is also illegal |
public function __destruct(): | public function __destruct(): | ||
} | } | ||
Line 72: | Line 74: | ||
</ | </ | ||
- | ===== Backward | + | ===== Backward |
- | Accepting this RFC results in a small backwards compatibility break in PHP 9.0 since it will no longer be legal to return | + | Accepting this RFC results in a small backwards compatibility break in PHP 9.0 since it will no longer be legal to return ('' |
- | The position of this RFC is that this BC break is minimal, as returning values from contructors/ | + | The position of this RFC is that this BC break is minimal, as returning values from constructors/ |
- | ===== Unaffected | + | ===== Unaffected |
==== Explicit return type declaration is optional ==== | ==== Explicit return type declaration is optional ==== | ||
Explicitly declaring the return type declaration would be optional. It would still be allowed to not specify a type at all: | Explicitly declaring the return type declaration would be optional. It would still be allowed to not specify a type at all: | ||
Line 109: | Line 111: | ||
===== Vote ===== | ===== Vote ===== | ||
- | 2/3 majority | + | Primary: Make constructors and destructors return void? Yes/no. |
+ | |||
+ | Secondary: Allow void return type on constructors/destructors? | ||
===== Implementation ===== | ===== Implementation ===== | ||
[[https:// | [[https:// |
rfc/make_ctor_ret_void.txt · Last modified: 2020/07/22 15:29 by moliata