Re: [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed

From: Date: Thu, 23 Apr 2020 14:07:58 +0000
Subject: Re: [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to internals+get-109811@lists.php.net to get a copy of this message
On Thu, 16 Apr 2020 at 18:46, tyson andre <tysonandre775@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.

« previous php.internals (#109811) next »