The ReflectionMethod class

(PHP 5, PHP 7, PHP 8)

Einführung

The ReflectionMethod class reports information about a method.

Klassenbeschreibung

class ReflectionMethod extends ReflectionFunctionAbstract {
/* Konstanten */
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;
/* Eigenschaften */
public string $class;
/* Geerbte Eigenschaften */
public string $name;
/* Methoden */
public function __construct(object|string $objectOrMethod, string $method)
public function __construct(string $classMethod)
public static function createFromMethodName(string $method): static
public static function export(string $class, string $name, bool $return = false): string
public function getClosure(?object $object = null): Closure
public function getModifiers(): int
public function getPrototype(): ReflectionMethod
public function hasPrototype(): bool
public function invoke(?object $object, mixed ...$args): mixed
public function invokeArgs(?object $object, array $args): mixed
public function isAbstract(): bool
public function isConstructor(): bool
public function isDestructor(): bool
public function isFinal(): bool
public function isPrivate(): bool
public function isProtected(): bool
public function isPublic(): bool
#[\Deprecated]
public function setAccessible(bool $accessible): void
public function __toString(): string
/* Geerbte Methoden */
public function ReflectionFunctionAbstract::getAttributes(?string $name = null, int $flags = 0): array
abstract public function ReflectionFunctionAbstract::__toString(): void
}

Eigenschaften

name

Method name

class

Class name

Vordefinierte Konstanten

ReflectionMethod Modifiers

ReflectionMethod::IS_STATIC int

Indicates that the method is static. Prior to PHP 7.4.0, the value was 1.

ReflectionMethod::IS_PUBLIC int

Indicates that the method is public. Prior to PHP 7.4.0, the value was 256.

ReflectionMethod::IS_PROTECTED int

Indicates that the method is protected. Prior to PHP 7.4.0, the value was 512.

ReflectionMethod::IS_PRIVATE int

Indicates that the method is private. Prior to PHP 7.4.0, the value was 1024.

ReflectionMethod::IS_ABSTRACT int

Indicates that the method is abstract. Prior to PHP 7.4.0, the value was 2.

ReflectionMethod::IS_FINAL int

Indicates that the method is final. Prior to PHP 7.4.0, the value was 4.

Hinweis:

The values of these constants may change between PHP versions. It is recommended to always use the constants and not rely on the values directly.

Changelog

Version Beschreibung
8.4.0 The class constants are now typed.
8.0.0 ReflectionMethod::export() was removed.

Inhaltsverzeichnis