ReflectionProperty::getType
Gets a property's type
Description
public ReflectionTypenull ReflectionProperty::getType()
Parameters
This function has no parameters.
Return Values
Returns a ReflectionType if the property has a type,
and null
otherwise.
Examples
Example #1 ReflectionProperty::getType example
<?php
class User
{
public string $name;
}
$rp = new ReflectionProperty('User', 'name');
echo $rp->getType()->getName();
?>
The above example will output:
See Also
- ReflectionProperty::hasType
- ReflectionProperty::isInitialized