The ReflectionMethod class

(PHP 5, PHP 7, PHP 8)

Introduction

The ReflectionMethod class reports information about a method.

Class synopsis

classReflectionMethodextendsReflectionFunctionAbstract {
publicconstintIS_STATIC;
publicconstintIS_PUBLIC;
publicconstintIS_PROTECTED;
publicconstintIS_PRIVATE;
publicconstintIS_ABSTRACT;
publicconstintIS_FINAL;
public__construct(object|string$objectOrMethod, string$method)
public__construct(string$classMethod)
publicstaticcreateFromMethodName(string$method): static
publicstaticexport(string$class, string$name, bool$return = false): string
publicgetClosure(?object$object = null): Closure
publicgetModifiers(): int
publicinvoke(?object$object, mixed...$args): mixed
publicinvokeArgs(?object$object, array$args): mixed
publicisAbstract(): bool
publicisFinal(): bool
publicisPrivate(): bool
publicisProtected(): bool
publicisPublic(): bool
publicsetAccessible(bool$accessible): 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.

Changelog

VersionDescription
8.0.0ReflectionMethod::export() was removed.

Table of Contents

To Top