Reflection ReflectionProperty::getType

(PHP 7 >= 7.4.0, PHP 8)

ReflectionProperty::getType — 속성의 유형을 가져옵니다.


설명

public ReflectionProperty::getType(): ?ReflectionType

속성의 연결된 유형을 가져옵니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

속성에 유형이 있으면 ReflectionType을 반환하고 그렇지 않으면 null을 반환합니다.


Examples

예제 #1 ReflectionProperty::getType() 예제

                  
<?php
class User
{
    public string $name;
}

$rp = new ReflectionProperty('User', 'name');
echo $rp->getType()->getName();
?>
                  
                

위의 예는 다음을 출력합니다.

string
                

기타