ReflectionProperty::hasType
(PHP 7 >= 7.4.0)
ReflectionProperty::hasType — プロパティが型を持つかをチェックする
説明
public ReflectionProperty::hasType ( ) : bool
プロパティが、自身に関連付けられた型を持つかをチェックします。
パラメータ
この関数にはパラメータはありません。
返り値
型が指定されていれば true
そうでなければ false
例
例1 ReflectionProperty::hasType() の例
<?phpclass User{ public string $name;}$rp = new ReflectionProperty('User', 'name');var_dump($rp->hasType());?>
上の例の出力は以下となります。
bool(true)
参考
- ReflectionProperty::getType() - プロパティの型を取得する
- ReflectionProperty::isInitialized() - プロパティが初期化されているかをチェックする