To be honest, I don’t see any use for interfaces in PHP. They seem very limited in use:
- Forcing all methods to be public makes them useless in a lot of scenarios.
- No properties are allowed.
- An abstract class can do everything interfaces do and a lot more.
I’ve been making several “importers” that allow users to upload the files from competing services and convert them to my format. All the importers could implement an iface called “IImporter”, or they could extend a class called “BaseImporter”.
I chose the second option because it allows common code, private abstract methods, properties, and has no downsides.
There is NOTHING an iface can do that a class can’t. In my opinion, interfaces are too limited to be much use beyond core functionality like ArrayAccess and Countable.
Edit: Sorry, the thread title makes no sense. I can’t edit it now though.