Jump to content

Inheritance confusion


OakBehringer

Recommended Posts

Hi. Could someone please tell me why this doesn't work?

 

<?php

 

interface iFace { }

class ManFace implements iFace {}

class WomanFace implements iFace {}

 

 

interface iJerk {

function slap (iFace $f);

}

 

class Pimp implements iJerk {

function slap (WomanFace $f) {}

}

 

?>

 

Fatal error: Declaration of Pimp::slap() must be compatible with that of iJerk::slap() in C:\Inetpub\wwwroot\www.networkautomation.com\order_new\test.php on line 12

 

Shouldn't class Pimp be able to restrict slap()'s parameter to WomanFace since WomanFace implements the iFace interface?

Link to comment
https://forums.phpfreaks.com/topic/40884-inheritance-confusion/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.