I am coming from C# and I am struggling to work out the PHP way of making my code extensible.
Lets say for instance I have a function that calculates my recommended daily allowance of food intake. It looks at vitamins, calories, minerals etc...
I want to have lots of different food objects that I use in my application and different functions that look at different aspects of food so I implement a IFoodNutrition interface and make my food classes that I want to be compatible with my function implement it. I then declare that my function takes it as an arg
function GetRda(IFoodNutrition $food){}
In C# I would specify all of the properties that I need to use in the interface so I know any class that implements this will be compatible with this function.
What is making my head hurt is that PHP only allows method signatures in interfaces.
My problems is obviously the paradigm shift. I am not sure what the equivalent pattern is in PHP. I have read the documentation and I can't see the like for like alternative unless you inherit from an abstract class but then you can only inherit from one class so that doesn't work the same way.
As PHP isn't typesafe I don't have to create the interface. Someone can just send any object to the method and if it has the properties needed in the right format it will work. This just doesn't seem right to me though as I am so used to laying out how things should be interacted with in interfaces.
I feel like there should at least be some extra step in the middle where the object is validated and some obvious structure that a developer can look at and then implement their own class intuitively and see errors before runtime.
Is there a specific pattern in PHP like this?