ReflectionMethod
class ReflectionMethod extends ReflectionFunctionAbstract (View source)
The ReflectionMethod class reports information about a method.
Constants
IS_STATIC |
Indicates that the method is static. |
IS_PUBLIC |
Indicates that the method is public. |
IS_PROTECTED |
Indicates that the method is protected. |
IS_PRIVATE |
Indicates that the method is private. |
IS_ABSTRACT |
Indicates that the method is abstract. |
IS_FINAL |
Indicates that the method is final. |
Properties
string | $name | ||
string | $class |
Methods
Returns the scope associated to the closure
Gets number of required parameters
Gets the specified return type of a function
Checks if the function has a specified return type
No description
Checks if method is static
Returns the string representation of the ReflectionMethod object.
Constructs a ReflectionMethod
Export a reflection method.
Checks if method is public
Checks if method is private
Checks if method is protected
Checks if method is abstract
Checks if method is final
Checks if method is a constructor
Checks if method is a destructor
Returns a dynamically created closure for the method
Gets the method modifiers
Invokes a reflected method.
Invokes the reflected method and pass its arguments as array.
Gets declaring class for the reflected method.
Gets the method prototype (if there is one).
Set method accessibility This method is no-op starting from PHP 8.1
No description
No description
Details
bool
inNamespace()
Checks if function in namespace
bool
isClosure()
Checks if closure
bool
isDeprecated()
Checks if deprecated
bool
isInternal()
Checks if is internal
bool
isUserDefined()
Checks if user defined
bool
isGenerator()
Returns whether this function is a generator
bool
isVariadic()
Returns whether this function is variadic
object|null
getClosureThis()
Returns this pointer bound to closure
ReflectionClass|null
getClosureScopeClass()
Returns the scope associated to the closure
ReflectionClass|null
getClosureCalledClass()
No description
string|false
getDocComment()
Gets doc comment
int|false
getEndLine()
Gets end line number
ReflectionExtension|null
getExtension()
Gets extension info
string|false
getExtensionName()
Gets extension name
string|false
getFileName()
Gets file name
string
getName()
Gets function name
string
getNamespaceName()
Gets namespace name
int
getNumberOfParameters()
Gets number of parameters
int
getNumberOfRequiredParameters()
Gets number of required parameters
array
getParameters()
Gets parameters
ReflectionType|null
getReturnType()
Gets the specified return type of a function
string
getShortName()
Gets function short name
int|false
getStartLine()
Gets starting line number
array
getStaticVariables()
Gets static variables
bool
returnsReference()
Checks if returns reference
bool
hasReturnType()
Checks if the function has a specified return type
array
getAttributes(string|null $name = null, int $flags = 0)
No description
array
getClosureUsedVariables()
No description
bool
hasTentativeReturnType()
No description
ReflectionType|null
getTentativeReturnType()
No description
bool
isStatic()
Checks if method is static
string
__toString()
Returns the string representation of the ReflectionMethod object.
__construct(string|object $objectOrMethod, string|null $method = null)
Constructs a ReflectionMethod
$reflection = new ReflectionMethod(new Example(), 'method');
$reflection = new ReflectionMethod(Example::class, 'method');
$reflection = new ReflectionMethod('Example::method');
static string|null
export(string $class, string $name, bool $return = false)
Export a reflection method.
bool
isPublic()
Checks if method is public
bool
isPrivate()
Checks if method is private
bool
isProtected()
Checks if method is protected
bool
isAbstract()
Checks if method is abstract
bool
isFinal()
Checks if method is final
bool
isConstructor()
Checks if method is a constructor
bool
isDestructor()
Checks if method is a destructor
Closure
getClosure(object|null $object = null)
Returns a dynamically created closure for the method
int
getModifiers()
Gets the method modifiers
mixed
invoke(object|null $object, mixed ...$args)
Invokes a reflected method.
mixed
invokeArgs(object|null $object, array $args)
Invokes the reflected method and pass its arguments as array.
ReflectionClass
getDeclaringClass()
Gets declaring class for the reflected method.
ReflectionMethod
getPrototype()
Gets the method prototype (if there is one).
void
setAccessible(bool $accessible)
Set method accessibility This method is no-op starting from PHP 8.1
bool
hasPrototype()
No description
static ReflectionMethod
createFromMethodName(string $method)
No description