On Thu, 16 Apr 2020 at 18:46, tyson andre <tysonandre...@hotmail.com> wrote:
> > Ah, so that's what this is about! In that case, I'd be happy to simply > > always enforce that __construct() cannot return a value, in the same way > we > > do for ": void" functions. (If we have backwards compatibility concerns, > we > > can add this as a warning instead of hard error.) > > I'd approve of that. It'd also be useful to enforce that __construct and > other magic methods aren't generators, > and that methods from traits renamed to __construct have the same > restrictions. > > ``` > php > class X{ public function __construct() { yield 2; }} > php > new X(); // nonsense > php > trait T1 { public function f() { echo "In f\n"; return 2; }} > php > class Z { use T1{ f as __construct; } } > php > new Z(); > In f > ``` > > - Tyson Hello Tyson, This falls under the `Future Scope` of the RFC ( https://wiki.php.net/rfc/magic-methods-signature#future-scope) as checking for the actual return value of these magic methods would be a larger BC. For now, only the signatures will be checked.