I'd like to know if a class is going to call a certain method, but I want to know before instantiating the class. Is this possible?
Example: class Controller_Index
calls $this->composite('SomeCompositeClass')
within its __construct()
method. Class SomeCompositeClass
has a helloWorld()
method. I want to see if I can call Controller_Index->helloWorld()
.
Basically I want to see if my controller is going to add any composite classes (by using $this->composite()
), so that I may check if those composite classes contain the method I'm requesting (helloWorld()
). And I'd like to do this without having to first instantiate Controller_Index
.
Thanks!
Edit
I suppose what I want to do is similar to using PHP's Reflection classes to see if a class method exists. But I don't want to know if the method exists, I want to know if the class calls it.
Edit 2
Interfaces won't help because I won't necessarily call $this->composite()
from every controller.
Perhaps I just need to rethink the problem and go with a different approach.