Php/docs/reflectionproperty.gettype
From Get docs
ReflectionProperty::getType
(PHP 7 >= 7.4.0)
ReflectionProperty::getType — Gets a property's type
Description
public ReflectionProperty::getType ( ) : ReflectionType|null
Gets the associated type of a property.
Parameters
This function has no parameters.
Examples
Example #1 ReflectionProperty::getType() example
<?phpclass User{ public string $name;}$rp = new ReflectionProperty('User', 'name');echo $rp->getType()->getName();?>
The above example will output:
string
See Also
- ReflectionProperty::hasType() - Checks if property has a type
- ReflectionProperty::isInitialized() - Checks whether a property is initialized