反射机制-ByStone--.docVIP

  • 2
  • 0
  • 约8.77千字
  • 约 9页
  • 2017-03-09 发布于江苏
  • 举报
反射机制-ByStone--

反射机制 用途: 该扩展分析php程序,导出或提取出关于类、方法、属性、参数等的详细信息,包括注释。 Reflection可以说是对php库函数:“Classes/Objects 类/对象函数”的一个扩展。 主要用在通过程序检测现有php程序内部关于类、方法等信息,并做出处理。 API概览: class Reflection { } interface Reflector { } class ReflectionException extends Exception { } class ReflectionFunction implements Reflector { } class ReflectionParameter implements Reflector { } class ReflectionMethod extends ReflectionFunction { } class ReflectionClass implements Reflector { } class ReflectionObject extends ReflectionClass { } class ReflectionProperty implements Reflector { } class ReflectionExtension implements Reflector { } 详细说明:(例子详见php手册) ①Reflection类 ?php class Reflection { public static mixed export(Reflector r [,bool return]) //导出一个类或方法的详细信息 public static array getModifierNames(int modifiers) //取得修饰符的名字 } ? ②ReflectionException类 该类继承标准类,没特殊方法和属性。 ③ReflectionFunction类 ?php class ReflectionFunction implements Reflector { final private __clone() public object __construct(string name) public string __toString() public static string export() //导出该函数的详细信息 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 mixed invoke(mixed* args) //调用该函数,通过参数列表传参数 public mixed invokeArgs(array args) //调用该函数,通过数组传参数 public bool returnsReference() //测试该函数是否返回引用 public ReflectionParameter[] getParameters() //取得该方法所需的参数,返回值为对象数组 public int getNumberOfParameters() //取得该方法所需的参数个数 public int getNumberOfRequiredParameters() //取得该方法所需的参数个数 } ? ④ReflectionParameter类: ?php class ReflectionParameter implements Reflector { final private __clone() public object __construct(string name) public string

文档评论(0)

1亿VIP精品文档

相关文档