Re: [RFC][DISCUSSION] Object type hint, now with added variance
| From: | Marc Bennewitz | Date: | Wed, 23 Nov 2016 11:07:13 +0000 |
| Subject: | Re: [RFC][DISCUSSION] Object type hint, now with added variance | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97144@lists.php.net to get a copy of this message | ||
Am 23.11.2016 um 01:52 schrieb Dan Ackroyd:
Hi, This is the reintroduction of the Object Type RFC for discussion. There was previously strong feedback from people who would prefer that the inheritance checks for methods that use object types should be co/contravariant. This has been added to the RFC. https://wiki.php.net/rfc/object-typehintI like this RFC :) And I have a question where I'm not sure if that should be catched by this RFC, too: If I declare a return type of "object" and extends that to return "static" it doesn't compile because "static" is not a valid return type yet. https://3v4l.org/lp3AB/rfc#version=rfc-typed-properties class Test {
public static function factory() : object {
return new static();
}
}
class Test2 extends Test {
public static function factory() : static {
return parent::factory();
}
}
cheers Dan Ack