(PHP 7 >= 7.4.0)
ReflectionProperty::getType — Gets a property's type
public ReflectionProperty::getType ( ) : ReflectionType|null
Gets the associated type of a property.
This function has no parameters.
Returns a ReflectionType if the property has a type, and null
otherwise.
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:
string
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/reflectionproperty.gettype.php