I am working with a legacy application where methods are returning some large associative arrays.
When adding functionality, it is very difficult to read / understand because whilst developing, it is difficult to establish without effort whether the correct array keys are being returned by each method in a given class.
I am aware that by programming to an interface, you are enforcing a contract - great, but doesn't solve the problem of enforcing return types.
Further, if the return type is an associative array, I need a way of programatically throwing an exception if the returned array does not contain the correct array keys.
Aside from creating a validation class as an in-between layer is there a sensible way of enforcing what is returned inside an associative array?