ReflectionProperty::hasType

(PHP 7 >= 7.4.0, PHP 8)

ReflectionProperty::hasTypeプロパティが型を持つかをチェックする

説明

public ReflectionProperty::hasType(): bool

プロパティが、自身に関連付けられた型を持つかをチェックします。

パラメータ

この関数にはパラメータはありません。

戻り値

型が指定されていれば true そうでなければ false

例1 ReflectionProperty::hasType() の例

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

$rp = new ReflectionProperty('User', 'name');
var_dump($rp->hasType());
?>

上の例の出力は以下となります。

bool(true)

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top