# 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 getDeclaringClass(): ReflectionClass
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 */
private function ReflectionFunctionAbstract::__clone(): void
public function ReflectionFunctionAbstract::getAttributes(?string `$name` = `null`, int `$flags` = 0): array
public function ReflectionFunctionAbstract::getClosureCalledClass(): ?ReflectionClass
public function ReflectionFunctionAbstract::getClosureScopeClass(): ?ReflectionClass
public function ReflectionFunctionAbstract::getClosureThis(): ?object
public function ReflectionFunctionAbstract::getClosureUsedVariables(): array
public function ReflectionFunctionAbstract::getDocComment(): string|false
public function ReflectionFunctionAbstract::getEndLine(): int|false
public function ReflectionFunctionAbstract::getExtension(): ?ReflectionExtension
public function ReflectionFunctionAbstract::getExtensionName(): string|false
public function ReflectionFunctionAbstract::getFileName(): string|false
public function ReflectionFunctionAbstract::getName(): string
public function ReflectionFunctionAbstract::getNamespaceName(): string
public function ReflectionFunctionAbstract::getNumberOfParameters(): int
public function ReflectionFunctionAbstract::getNumberOfRequiredParameters(): int
public function ReflectionFunctionAbstract::getParameters(): array
public function ReflectionFunctionAbstract::getReturnType(): ?ReflectionType
public function ReflectionFunctionAbstract::getShortName(): string
public function ReflectionFunctionAbstract::getStartLine(): int|false
public function ReflectionFunctionAbstract::getStaticVariables(): array
public function ReflectionFunctionAbstract::getTentativeReturnType(): ?ReflectionType
public function ReflectionFunctionAbstract::hasReturnType(): bool
public function ReflectionFunctionAbstract::hasTentativeReturnType(): bool
public function ReflectionFunctionAbstract::inNamespace(): bool
public function ReflectionFunctionAbstract::isClosure(): bool
public function ReflectionFunctionAbstract::isDeprecated(): bool
public function ReflectionFunctionAbstract::isGenerator(): bool
public function ReflectionFunctionAbstract::isInternal(): bool
public function ReflectionFunctionAbstract::isStatic(): bool
public function ReflectionFunctionAbstract::isUserDefined(): bool
public function ReflectionFunctionAbstract::isVariadic(): bool
public function ReflectionFunctionAbstract::returnsReference(): bool
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

- ReflectionMethod::__construct — Constructs a ReflectionMethod
- ReflectionMethod::createFromMethodName — Creates a new ReflectionMethod
- ReflectionMethod::export — Export a reflection method
- ReflectionMethod::getClosure — Returns a dynamically created closure for the method
- ReflectionMethod::getDeclaringClass — Gets declaring class for the reflected method
- ReflectionMethod::getModifiers — Gets the method modifiers
- ReflectionMethod::getPrototype — Gets the method prototype (if there is one)
- ReflectionMethod::hasPrototype — Returns whether a method has a prototype
- ReflectionMethod::invoke — Invoke
- ReflectionMethod::invokeArgs — Invoke args
- ReflectionMethod::isAbstract — Checks if method is abstract
- ReflectionMethod::isConstructor — Checks if method is a constructor
- ReflectionMethod::isDestructor — Checks if method is a destructor
- ReflectionMethod::isFinal — Checks if method is final
- ReflectionMethod::isPrivate — Checks if method is private
- ReflectionMethod::isProtected — Checks if method is protected
- ReflectionMethod::isPublic — Checks if method is public
- ReflectionMethod::setAccessible — Set method accessibility
- ReflectionMethod::__toString — Returns the string representation of the Reflection method object

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open