The ReflectionParameter class

(PHP 5, PHP 7, PHP 8)

Introduction

The ReflectionParameter class retrieves information about function's or method's parameters.

To introspect function parameters, first create an instance of the ReflectionFunction or ReflectionMethod classes and then use their ReflectionFunctionAbstract::getParameters() method to retrieve an array of parameters.

Class synopsis

class ReflectionParameter implements Reflector {
/* Properties */
public string $name;
/* Methods */
public __construct(string|array|object $function, int|string $param)
public allowsNull(): bool
public canBePassedByValue(): bool
private __clone(): void
public static export(string $function, string $parameter, bool $return = ?): string
public getAttributes(?string $name = null, int $flags = 0): array
public getDefaultValueConstantName(): ?string
public getName(): string
public getPosition(): int
public hasType(): bool
public isArray(): bool
public isCallable(): bool
public isDefaultValueConstant(): bool
public isOptional(): bool
public isPassedByReference(): bool
public isVariadic(): bool
public __toString(): string
}

Properties

name

Name of the parameter. Read-only, throws ReflectionException in attempt to write.

Table of Contents