I am going through a list of objects, all with the same parent class but they could be instances from one of many sub classes. Depending on the true type of the object I want to perform slightly different operations.
How can I run different blocks of code based on the object types?
In Java I would overload a processing function with each type I wanted to work with, but PHP doesn't allow this.
Background: To Gordon's comment.
We are building forms from a group of objects. A super class Component that is extended to represent specific types of form elements. TextInput extends Component
and the Component has the ability to hold other Components. We don't want them to be responsible for their actual representation.
We are working to build HTML right now, but we might potentially want to use them to build .PDFs or other formats.
So we have code that goes through the Components, and recursively through the Components it contains. Depending on the type of the Component, we need to create different output.