In short I have
abstract class AbstractMapper implements MapperInterface {
public function fetch(EntityInterface $entity, Array $conditions = array()) {
. . .
}
}
interface MapperInterface {
public function fetch(EntityInterface $entity, Array $conditions = array());
}
abstract class AbstractUserMapper extends AbstractMapper implements UserMapperInterface {
public function fetch(UserInterface $user, Array $conditions = array()) {
$conditions = array_merge($conditions, array('type' => $user->getType()));
return parent::fetch($user, $conditions);
}
}
interface UserMapperInterface {
public function fetch(UserInterface $user, Array $conditions = array());
}
This is the error I get:
Fatal error: Declaration of Model\Data\Mappers\AbstractUserMapper::fetch() must be compatible with that of Model\Data\Mappers\Interfaces\MapperInterface::fetch()
If I change the UserInterface
to EntityInterface
it works but it just seems wrong and also in my AbstractUserMapper::fetch()
when I type$user
my IDE shows only the methods declared in my EntityInterface
and getType()
is not in that list.
I know I can still put $user->getType()
because I know the object I have implements the UserInterface
but it all just seems wrong, even my IDE thinks so or am I missing something here?
Why does this not work? It is messing up my code if I have to put EntityInterface
instead of 'UserInterface
I think.