(PHP 7 >= 7.4.0, PHP 8)
ReflectionProperty::hasType — 检查属性是否具有类型
检查属性是否关联了类型。
此函数没有参数。
如果指定了类型,则返回true,否则返回false。
true
false
示例 #1 ReflectionProperty::hasType() 示例
<?phpclass User{ public string $name;}$rp = new ReflectionProperty('User', 'name');var_dump($rp->hasType());?>
以上示例将输出
bool(true)