(PHP 7 >= 7.4.0, PHP 8)
ReflectionProperty::getType — Gets a property's type
此函数没有参数。
Returns a ReflectionType if the property has a type,
and null
otherwise.
示例 #1 ReflectionProperty::getType() example
<?php
class User
{
public string $name;
}
$rp = new ReflectionProperty('User', 'name');
echo $rp->getType()->getName();
?>
以上示例会输出:
string