|
ReflectionParameter::getTypeGets a parameter's type Description
public ReflectionTypenull ReflectionParameter::getType()
Gets the associated type of a parameter. ParametersThis function has no parameters. Return Values
Returns a ReflectionType object if a parameter type is
specified, Examples
Example #1 ReflectionParameter::getType Usage as of PHP 7.1.0 As of PHP 7.1.0, ReflectionType::__toString is deprecated, and ReflectionParameter::getType may return an instance of ReflectionNamedType. To get the name of the parameter type, ReflectionNamedType is available in this case.
The above example will output: int NULL
Example #2 ReflectionParameter::getType Usage before PHP 7.1.0
Output of the above example in PHP 7.0: int NULL Example #3 ReflectionParameter::getType Usage in PHP 8.0.0 and later
As of PHP 8.0.0, this method may return a ReflectionNamedType instance or
a ReflectionUnionType instance. The latter is a collection of the former.
To analyze a type, it is often convenient to normalize it to an array of ReflectionNamedType
objects. The following function will return an array of
See Also
|