> On 6 Nov 2014, at 00:26, Andrea Faulds <a...@ajf.me> wrote: > >> Also, it is kind of weird that arguments require exact match but return >> types do not. Not that we care for consistency anymore… > > Yeah, we should probably have arguments be contravariant or covariant. > > I was going to argue that covariance is important, but now that I think about > it, the most important case is just self. If I can have Foo::foo() return a > Foo and Bar::foo() return a Bar, with Bar inheriting from Foo, and this not > breaking the invariant type check, I’m happy.
What I meant there wasn’t `self`, but actually `static`, I think, which sadly this RFC doesn’t provide. I think that’d be a very useful feature. If we can’t get covariant returns and must go for invariants, I think we’d have to have `static` supported. I note that Hack also has invariant parameters and covariant return types. There’s probably some good reasoning behind that, I think it’d be worth asking some HHVM people about why that decision was taken, they might provide some useful insight. -- Andrea Faulds http://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php