> Le 14 avr. 2020 à 16:54, Nicolas Grekas <nicolas.grekas+...@gmail.com> a > écrit : > > I'm just not sold on allowing "void" on __construct, because the very concept > of a return type on a constructor is ... void, and also because of the code > style choices this will open (and the CS "wars" I mentioned). >
This issue is not specific to magic method like __construct(). It is the whole concept of “void” as return type which is, say, “problematic”. In fact, “void” is not really a return type. It is a way to state that the method is not supposed to return anything, which means, as you said very well, that “the very concept of return type on [this method] is void”. That might be a reason to reject the concept of “void” as return type. Or to revive https://wiki.php.net/rfc/allow-void-variance <https://wiki.php.net/rfc/allow-void-variance> . But again, the issue is orthogonal to the fact that this particular method is magic, and we should not cherry-pick and reject the concept of “void” for __construct() and similar magic methods only. —Claude