The ReflectionMethod class lets you reverse-engineer class methods.
<?php
class ReflectionMethod extends ReflectionFunction {
public __construct(mixed class, string name)
public mixed invoke(stdclass object, mixed* args)
public bool isFinal()
public bool isAbstract()
public bool isPublic()
public bool isPrivate()
public bool isProtected()
public bool isStatic()
public bool isConstructor()
public int getModifiers()
public ReflectionClass getDeclaringClass()
/* Inherited from ReflectionFunction */
public string getName()
public bool isInternal()
public bool isUserDefined()
public string getFileName()
public int getStartLine()
public int getEndLine()
public string getDocComment()
public array getStaticVariables()
public string toString()
public bool returnsReference()
public ReflectionParameter[] getParameters()
}
?> |
To introspect a method, you will first have to create an instance of the ReflectionMethod class. You can then call any of the above methods on this instance.
Note: Trying to invoke private, protected or abstract methods will result in an exception being thrown from the invoke() method.
Note: For static methods as seen above, you should pass NULL as the first argument to invoke(). For non-static methods, pass an instance of the class.