ReflectionProperty::getType
(PHP 7 >= 7.4.0)
ReflectionProperty::getType — プロパティの型を取得する
パラメータ
この関数にはパラメータはありません。
例
例1 ReflectionProperty::getType() の例
<?phpclass User{ public string $name;}$rp = new ReflectionProperty('User', 'name');echo $rp->getType()->getName();?>
上の例の出力は以下となります。
string
参考
- ReflectionProperty::hasType() - プロパティが型を持つかをチェックする
- ReflectionProperty::isInitialized() - プロパティが初期化されているかをチェックする