Re: Using child classes/interfaces as desired type hints
| From: | Ionut G. Stan | Date: | Thu, 07 Oct 2010 08:02:55 +0000 |
| Subject: | Re: Using child classes/interfaces as desired type hints | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49883@lists.php.net to get a copy of this message | ||
On 07/Oct/10 8:56 AM, Nathan Nobbe wrote:
Hi, Probly rehashing an old conversation here, but I'm wondering why the following isn't supported <?php abstract class AbstractServer {} class ConcreteServer extends AbstractServer {} abstract class AbstractClient { abstract function doStuff(AbstractServer $o); } class ConcreteClient extends AbstractClient { function doStuff(ConcreteServer $o) {} } ?>Here's the problem:
class ConcreteServer2 extends AbstractServer
{}
Now, ConcreteClient can't receive an instance of ConcreteServer2 as an argument, although the initial hint, AbstractServer would have allowed it.
--
Ionuț G. Stan | http://igstan.ro