> 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.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to