Re: [RFC][Discussion] Return Type Variance Checking

From: Date: Tue, 25 Nov 2014 18:14:32 +0000
Subject: Re: [RFC][Discussion] Return Type Variance Checking
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-79173@lists.php.net to get a copy of this message
> It should be mentioned for Option 3 that covariant return types are not supported just at the > definition level . Even with invariant return types the following is perfectly fine: > class A { > function foo(): B { return new B; } > } > > class B extends A { > function foo(): B { return new C; } > } Yes, this is correct; thank you for the clarification. The phrase "covariant return types" in the RFC and in my message above refers to the declared type in the function signature, not the type returned by the method. The value that is returned can always be subtype of the declared type.

« previous php.internals (#79173) next »