Hello, I like the proposal. I also support the covariance.
One question though. The RFC mentions possible future use of "nothing" as a bottom type for parameters in generics. This makes a lot of sense to me. Even without generics, it could be used for parameters in abstract methods. So why not already introduce "nothing" as the universal bottom type, and use it instead of "noreturn"? Can "noreturn" do anything that "nothing" can't? -- Andreas On Tue, 30 Mar 2021 at 07:18, Matthew Brown <matthewmatt...@gmail.com> wrote: > > On Mar 29, 2021, at 1:25 PM, Ilija Tovilo <tovilo.il...@gmail.com> > wrote: > > > > Hi Matthew > > > >> Ondřej Mirtes and I present an RFC for the noreturn type: > >> https://wiki.php.net/rfc/noreturn_type > >> > >> The feature already exists in Hack (the primary inspiration) and is > >> currently supported by our static analysis tools inside docblocks, and > we > >> feel there's a good argument for it to be supported by PHP itself. > > > > Thanks for the RFC! I'm very much in support of it. > > > > Two small things: > > > > 1. Some magic methods like __toString currently require a specific > > return type (like string in that case). Since noreturn is a bottom > > type technically it should be possible to type hint those magic > > methods with noreturn. It's not a big issue if that's not possible, > > but it should be mentioned in the RFC. > > > > 2. noreturn is one of the few return types that would technically make > > sense for __construct (other than void). > > > > class Foo { > > public function __construct(): noreturn { > > throw new Exception(); > > } > > } > > > > new Foo(); > > bar(); // < Dead code > > > > Not sure this is worth supporting but I just wanted to mention it. > > > > Ilija > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: https://www.php.net/unsub.php > > > > Thanks, I’ll update the RFC to mention __toString, but I’ll steer clear of > __construct > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >