CHAPTER 5 ■ OBJECT TOOLS
96
Before you can invoke the execute() method of each Module, an instance has to be created. That’s
the purpose of method::ReflectionClass::newInstance(). That method accepts any number of
arguments, which it passes on to the relevant class’s constructor method. If all’s well, it returns an
instance of the class (for production code, be sure to code defensively: check that the constructor
method for each Module object doesn’t require arguments before creating an instance).
ReflectionClass::getMethods() returns an array of all ReflectionMethod objects available for the
class. For each element in the array, the code invokes the ModuleRunner::handleMethod() method; passes
it a Module instance, the ReflectionMethod object, ...