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

From: Date: Thu, 16 Apr 2020 16:46:24 +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  Groups: php.internals 
Request: Send a blank email to internals+get-109691@lists.php.net to get a copy of this message
> 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

« previous php.internals (#109691) next »