PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I can't seem to create an interface that allows me to specify a class type in the method, then specify a subclass type in the implemented version of the method. I'm trying to find a way to do this without having to manually check the type inside of the implemented method. Here's an example of what I'm after:
SpecificAdder has to implement the method of the interface. This method has to accept every Item_Abstract object, not a specific one.
Adding an additional method that takes another type of parameter is a kind of polymorphism/overloading unsupported by php.
So then technically, add() wouldn't even be a part of the interface, but a part of each individual implemented class, and each should be treated separately?
Well, the interface says "if it's a TestInterface it has a method add(Item_Abstract)"
If you class does not have this method it's not a TestInterface. If you interface makes no sense with this method, the method doesn't belong to the interface.