My question is : in PHP are interfaces really useful for developers that build website applications on their own ? Isn’t an abstract class providing all the things an interface provides ?
If an interface is just a “contract” isn’t the developer aware of the things the class should implement ?
The only single benefit I can think of is that a class can implement multiple interfaces but again how useful is this .. when you know everything a class should implement. You just force yourself to implement those methods.
As you can figure out I’m still waiting for that A-HA moment when I really understand why an interface is useful.
To wrap this up and put it simple : When should I use interfaces and why not use abstract classes instead ?
Just because you “know” what something should implement, doesn’t mean you remember it. It doesn’t mean you’ll never make a mistake and typo a function name. “Contracts” in programming aren’t just for one developer to enforce things on another – they also let you provide a rigidity to the code that can catch mistakes that might otherwise slip under the radar.