ReflectionParameter::hasType
(PHP 7)
ReflectionParameter::hasType — 引数が型を持つかを調べる
説明
public ReflectionParameter::hasType ( ) : bool
引数が、関連する型を持つかを調べます。
パラメータ
この関数にはパラメータはありません。
返り値
型が指定されていれば true
を。そうでなければ false
を返します。
例
例1 ReflectionParameter::hasType() の例
<?phpfunction someFunction(string $param, $param2 = null) {}$reflectionFunc = new ReflectionFunction('someFunction');$reflectionParams = $reflectionFunc->getParameters();var_dump($reflectionParams[0]->hasType());var_dump($reflectionParams[1]->hasType());
上の例の出力は、 たとえば以下のようになります。
bool(true) bool(false)