The ReflectionMethod class

From Get docs
Php/docs/latest/class.reflectionmethod


The ReflectionMethod class

Introduction

(PHP 5, PHP 7, PHP 8)

The ReflectionMethod class reports information about a method.

Class synopsis

class ReflectionMethod extends ReflectionFunctionAbstract implements Reflector {

/* Constants */

const int IS_STATIC = 16;

const int IS_PUBLIC = 1;

const int IS_PROTECTED = 2;

const int IS_PRIVATE = 4;

const int IS_ABSTRACT = 64;

const int IS_FINAL = 32;

/* Properties */

public $name;

public $class;

/* Methods */

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 getDeclaringClass(): ReflectionClass
public getModifiers(): int
public getPrototype(): ReflectionMethod
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 isStatic(): bool
public setAccessible(bool $accessible): void
public __toString(): string

/* Inherited methods */

final private ReflectionFunctionAbstract::__clone(): void
public ReflectionFunctionAbstract::getAttributes(?string $name = null, int $flags = 0): array
public ReflectionFunctionAbstract::getClosureScopeClass(): ?ReflectionClass
public ReflectionFunctionAbstract::getClosureThis(): ?object
public ReflectionFunctionAbstract::getDocComment(): string|false
public ReflectionFunctionAbstract::getEndLine(): int|false
public ReflectionFunctionAbstract::getExtension(): ?ReflectionExtension
public ReflectionFunctionAbstract::getExtensionName(): string|false
public ReflectionFunctionAbstract::getFileName(): string|false
public ReflectionFunctionAbstract::getName(): string
public ReflectionFunctionAbstract::getNamespaceName(): string
public ReflectionFunctionAbstract::getNumberOfParameters(): int
public ReflectionFunctionAbstract::getNumberOfRequiredParameters(): int
public ReflectionFunctionAbstract::getParameters(): array
public ReflectionFunctionAbstract::getReturnType(): ?ReflectionType
public ReflectionFunctionAbstract::getShortName(): string
public ReflectionFunctionAbstract::getStartLine(): int|false
public ReflectionFunctionAbstract::getStaticVariables(): array
public ReflectionFunctionAbstract::hasReturnType(): bool
public ReflectionFunctionAbstract::inNamespace(): bool
public ReflectionFunctionAbstract::isClosure(): bool
public ReflectionFunctionAbstract::isDeprecated(): bool
public ReflectionFunctionAbstract::isGenerator(): bool
public ReflectionFunctionAbstract::isInternal(): bool
public ReflectionFunctionAbstract::isUserDefined(): bool
public ReflectionFunctionAbstract::isVariadic(): bool
public ReflectionFunctionAbstract::returnsReference(): bool
abstract public ReflectionFunctionAbstract::__toString(): void

}

Properties

name
Method name
class
Class name

Predefined Constants

ReflectionMethod Modifiers

ReflectionMethod::IS_STATIC
Indicates that the method is static. Prior to PHP 7.4.0, the value was 1.
ReflectionMethod::IS_PUBLIC
Indicates that the method is public. Prior to PHP 7.4.0, the value was 256.
ReflectionMethod::IS_PROTECTED
Indicates that the method is protected. Prior to PHP 7.4.0, the value was 512.
ReflectionMethod::IS_PRIVATE
Indicates that the method is private. Prior to PHP 7.4.0, the value was 1024.
ReflectionMethod::IS_ABSTRACT
Indicates that the method is abstract. Prior to PHP 7.4.0, the value was 2.
ReflectionMethod::IS_FINAL
Indicates that the method is final. Prior to PHP 7.4.0, the value was 4.

Note:

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.

Table of Contents


© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.reflectionmethod.php