Re: [PHP-DEV] Covariance, again

2017-12-18 Thread Andreas Hennings
> I really think we ought to tackle covariant returns and contravariant > parameters My "algorithm" could be extended for contravariance: Whenever a method has a parameter type hint that differs from the parent type hint, autoload the class of the parent type hint. I think I know too little abou

Re: [PHP-DEV] Covariance, again

2017-12-18 Thread Levi Morrison
On Mon, Dec 18, 2017 at 11:52 AM, Andreas Hennings wrote: >> I believe your algorithm fails on this simple setup: > > Another comment I want to make here: > The examples you give each have multiple class declarations per file. > I would personally not care much, if these result in fatal error. > A

Re: [PHP-DEV] Covariance, again

2017-12-18 Thread Andreas Hennings
> I believe your algorithm fails on this simple setup: Another comment I want to make here: The examples you give each have multiple class declarations per file. I would personally not care much, if these result in fatal error. All of this code used to be illegal until now (because no covariance s

Re: [PHP-DEV] Covariance, again

2017-12-18 Thread Andreas Hennings
Ok, I think I missed the circularity aspect in your examples. Inheritance by itself is never circular. However, return types can make this entire thing circular. So the problem would be if we try to autoload the same thing that is currently in the process of being being defined. Maybe we could ge

Re: [PHP-DEV] Covariance, again

2017-12-18 Thread Andreas Hennings
Let me address the simple example first. On 18 December 2017 at 15:45, Levi Morrison wrote: > > I believe your algorithm fails on this simple setup: > > > interface A { > function foo(): X; > } > > interface B extends A { > function foo(): Y; > } > > interface X { > function bar(): A

Re: [PHP-DEV] Covariance, again

2017-12-18 Thread Levi Morrison
On Mon, Dec 18, 2017 at 5:18 AM, Andreas Hennings wrote: > There were discussions about covariance and contravariance in the past. > https://externals.io/message/98085#98105 > Unfortunately I was not subscribed back then, so I cannot respond to anything. > So, here it goes again. > > WIth co- and