ReflectionMethod 类
(PHP 5, PHP 7, PHP 8)
简介
ReflectionMethod 类报告有关方法的信息。
类摘要
/* 常量 */
/* 属性 */
/* 继承的属性 */
/* 方法 */
/* 继承的方法 */
}属性
- name
-
方法名
- class
-
类名
预定义常量
ReflectionMethod 修饰符
-
ReflectionMethod::IS_STATICint -
表示该方法是 static。在 PHP 7.4.0 之前,值为
1。 -
ReflectionMethod::IS_PUBLICint -
表示该方法是 public。在 PHP 7.4.0 之前,值为
256。 -
ReflectionMethod::IS_PROTECTEDint -
表示该方法是 protected。在 PHP 7.4.0 之前,值为
512。 -
ReflectionMethod::IS_PRIVATEint -
表示该方法是 private。在 PHP 7.4.0 之前,值为
1024。 -
ReflectionMethod::IS_ABSTRACTint -
表示该方法是 abstract。PHP 7.4.0 之前,值为
2。 -
ReflectionMethod::IS_FINALint -
表示该方法是 final。PHP 7.4.0 之前,值为
4。
注意:
这些常量的值可能会在不同 PHP 版本间发生更改。建议始终使用常量而不直接依赖值。
更新日志
| 版本 | 说明 |
|---|---|
| 8.4.0 | 所有类常量现已类型化。 |
| 8.0.0 | 已移除 ReflectionMethod::export()。 |
目录
- ReflectionMethod::__construct — 构造 ReflectionMethod
- ReflectionMethod::createFromMethodName — Creates a new ReflectionMethod
- ReflectionMethod::export — 导出 reflection 方法
- ReflectionMethod::getClosure — 返回动态建立的方法调用接口(译者注:可以使用这个返回值直接调用非公开方法)
- ReflectionMethod::getDeclaringClass — 获取被反射的方法所在类的反射实例
- ReflectionMethod::getModifiers — 获取方法的修饰符
- ReflectionMethod::getPrototype — 返回方法原型 (如果存在)
- ReflectionMethod::hasPrototype — Returns whether a method has a prototype
- ReflectionMethod::invoke — Invoke
- ReflectionMethod::invokeArgs — 带参数执行
- ReflectionMethod::isAbstract — 判断方法是否是抽象方法
- ReflectionMethod::isConstructor — 判断方法是否是构造方法
- ReflectionMethod::isDestructor — 判断方法是否是析构方法
- ReflectionMethod::isFinal — 判断方法是否定义 final
- ReflectionMethod::isPrivate — 判断方法是否是私有
- ReflectionMethod::isProtected — 判断方法是否是 protected
- ReflectionMethod::isPublic — 判断方法是否是 public
- ReflectionMethod::setAccessible — 设置方法是否可访问
- ReflectionMethod::__toString — 返回反射方法对象的字符串表达