ReflectionMethod 类

(PHP 5, PHP 7, PHP 8)

简介

ReflectionMethod 类报告有关方法的信息。

类摘要

class ReflectionMethod extends ReflectionFunctionAbstract {
/* 常量 */
public const int IS_STATIC;
public const int IS_PUBLIC;
public const int IS_PROTECTED;
public const int IS_PRIVATE;
public const int IS_ABSTRACT;
public const int IS_FINAL;
/* 属性 */
public string $class;
/* 继承的属性 */
public string $name;
/* 方法 */
public __construct(object|string $objectOrMethod, string $method)
public __construct(string $classMethod)
public static export(string $class, string $name, bool $return = false): string
public getClosure(?object $object = null): Closure
public getModifiers(): int
public hasPrototype(): bool
public invoke(?object $object, mixed ...$args): mixed
public invokeArgs(?object $object, array $args): mixed
public isAbstract(): bool
public isConstructor(): bool
public isDestructor(): bool
public isFinal(): bool
public isPrivate(): bool
public isProtected(): bool
public isPublic(): bool
public setAccessible(bool $accessible): void
public __toString(): string
/* 继承的方法 */
public ReflectionFunctionAbstract::getAttributes(?string $name = null, int $flags = 0): array
}

属性

name

方法名

class

类名

预定义常量

ReflectionMethod 修饰符

ReflectionMethod::IS_STATIC

表示该方法是 static。在 PHP 7.4.0 之前,值为 1

ReflectionMethod::IS_PUBLIC

表示该方法是 public。在 PHP 7.4.0 之前,值为 256

ReflectionMethod::IS_PROTECTED

表示该方法是 protected。在 PHP 7.4.0 之前,值为 512

ReflectionMethod::IS_PRIVATE

表示该方法是 private。在 PHP 7.4.0 之前,值为 1024

ReflectionMethod::IS_ABSTRACT

表示该方法是 abstract。PHP 7.4.0 之前,值为 2

ReflectionMethod::IS_FINAL

表示该方法是 final。PHP 7.4.0 之前,值为 4

注意:

这些常量的值可能会在不同 PHP 版本间发生更改。建议始终使用常量而不直接依赖值。

更新日志

版本 说明
8.0.0 已移除 ReflectionMethod::export()

目录

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top