class ReflectionFunction extends ReflectionFunctionAbstract (View source)

The ReflectionFunction class reports information about a function.

Constants

IS_DEPRECATED

Indicates deprecated functions.

Properties

string $name

Methods

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

getClosureScopeClass()

Returns the scope associated to the closure

string|false
getDocComment()

Gets doc comment

int|false
getEndLine()

Gets end line number

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

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

bool
isStatic()

No description

string
__toString()

Returns the string representation of the ReflectionFunction object.

__construct(string|Closure $function)

Constructs a ReflectionFunction object

static string|null
export(string $name, bool $return = false)

Exports function

bool
isDisabled()

Checks if function is disabled

mixed
invoke(mixed ...$args)

Invokes function

mixed
invokeArgs(array $args)

Invokes function args

getClosure()

Returns a dynamically created closure for the function

bool
isAnonymous()

No description

Details

bool inNamespace()

Checks if function in namespace

Return Value

bool

{\true} if it's in a namespace, otherwise {\false}

bool isClosure()

Checks if closure

Return Value

bool

{\true} if it's a closure, otherwise {\false}

bool isDeprecated()

Checks if deprecated

Return Value

bool

{\true} if it's deprecated, otherwise {\false}

bool isInternal()

Checks if is internal

Return Value

bool

{\true} if it's internal, otherwise {\false}

bool isUserDefined()

Checks if user defined

Return Value

bool

{\true} if it's user-defined, otherwise {\false}

bool isGenerator()

Since: 5.5

Returns whether this function is a generator

Return Value

bool

{\true} if the function is generator, otherwise {\false}

bool isVariadic()

Since: 5.6

Returns whether this function is variadic

Return Value

bool

{\true} if the function is variadic, otherwise {\false}

object|null getClosureThis()

Returns this pointer bound to closure

Return Value

object|null

Returns $this pointer or {\null} in case of an error.

ReflectionClass|null getClosureScopeClass()

Since: 5.4

Returns the scope associated to the closure

Return Value

ReflectionClass|null

Returns the class on success or {\null} on failure.

ReflectionClass|null getClosureCalledClass()

Since: 8.0

No description

Return Value

ReflectionClass|null

Returns the class on success or {\null} on failure.

string|false getDocComment()

Gets doc comment

Return Value

string|false

The doc comment if it exists, otherwise {\false}

int|false getEndLine()

Gets end line number

Return Value

int|false

The ending line number of the user defined function, or {\false} if unknown.

ReflectionExtension|null getExtension()

Gets extension info

Return Value

ReflectionExtension|null

The extension information, as a {\ReflectionExtension} object or {\null} instead.

string|false getExtensionName()

Gets extension name

Return Value

string|false

The extension's name or {\false} instead.

string|false getFileName()

Gets file name

Return Value

string|false

The file name or {\false} in case of error.

string getName()

Gets function name

Return Value

string

The name of the function.

string getNamespaceName()

Gets namespace name

Return Value

string

The namespace name.

int getNumberOfParameters()

Since: 5.0.3

Gets number of parameters

Return Value

int

The number of parameters.

int getNumberOfRequiredParameters()

Since: 5.0.3

Gets number of required parameters

Return Value

int

The number of required parameters.

array getParameters()

Gets parameters

Return Value

array

The parameters, as a ReflectionParameter objects.

ReflectionType|null getReturnType()

Since: 7.0

Gets the specified return type of a function

Return Value

ReflectionType|null

Returns a {\ReflectionType} object if a return type is specified, {\null} otherwise.

string getShortName()

Gets function short name

Return Value

string

The short name of the function.

int|false getStartLine()

Gets starting line number

Return Value

int|false

The starting line number or {\false} if unknown.

array getStaticVariables()

Gets static variables

Return Value

array

An array of static variables.

bool returnsReference()

Checks if returns reference

Return Value

bool

{\true} if it returns a reference, otherwise {\false}

bool hasReturnType()

Since: 7.0

Checks if the function has a specified return type

Return Value

bool

Returns {\true} if the function is a specified return type, otherwise {\false}.

array getAttributes(string|null $name = null, int $flags = 0)

Since: 8.0

No description

Parameters

string|null $name

Name of an attribute class

int $flags

Сriteria by which the attribute is searched.

Return Value

array

array getClosureUsedVariables()

No description

Return Value

array

bool hasTentativeReturnType()

No description

Return Value

bool

ReflectionType|null getTentativeReturnType()

No description

Return Value

ReflectionType|null

bool isStatic()

No description

Return Value

bool

string __toString()

Returns the string representation of the ReflectionFunction object.

Return Value

string

Returns string representation of the object that implements this interface (and/or "__toString" magic method).

__construct(string|Closure $function)

Constructs a ReflectionFunction object

Parameters

string|Closure $function

The name of the function to reflect or a closure.

Exceptions

ReflectionException

static string|null export(string $name, bool $return = false)

Exports function

Parameters

string $name

The reflection to export.

bool $return

Setting to {\true} will return the export, as opposed to emitting it. Setting to {\false} (the default) will do the opposite.

Return Value

string|null

bool isDisabled()

Checks if function is disabled

Return Value

bool

{\true} if it's disable, otherwise {\false}

mixed invoke(mixed ...$args)

Invokes function

Parameters

mixed ...$args

[optional] The passed in argument list. It accepts a variable number of arguments which are passed to the function much like {\call_user_func} is.

Return Value

mixed

Returns the result of the invoked function call.

mixed invokeArgs(array $args)

Invokes function args

Parameters

array $args

The passed arguments to the function as an array, much like {\call_user_func_array} works.

Return Value

mixed

the result of the invoked function

Closure getClosure()

Returns a dynamically created closure for the function

Return Value

Closure

Returns {\Closure} or {\null} in case of an error.

bool isAnonymous()

No description

Return Value

bool