ReflectionParameter::getClass
(PHP 5, PHP 7, PHP 8)
ReflectionParameter::getClass — Get a ReflectionClass object for the parameter being reflected or null
WarningThis function has been
DEPRECATED as of PHP 8.0.0. Relying on this function
is highly discouraged.
Description
#[\Deprecated(
since: '8.0',
message: "use ReflectionParameter::getType() instead",
)]
public function ReflectionParameter::getClass():
?ReflectionClass
As of PHP 8.0.0 this function is deprecated and not recommended. Instead, use
ReflectionParameter::getType() to get the ReflectionType
of the parameter, then interrogate that object to determine the parameter type.
WarningThis function is
currently not documented; only its argument list is available.
Parameters
This function has no parameters.
Return Values
A ReflectionClass object, or null if no type is declared,
or the declared type is not a class or interface.
Examples
Example #1 Using the ReflectionParameter class
<?php
function foo(Exception $a) { }
$functionReflection = new ReflectionFunction('foo');
$parameters = $functionReflection->getParameters();
$aParameter = $parameters[0];
echo $aParameter->getClass()->name;
?>