PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

ReflectionParameter::hasType - Checks if parameter has a type | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

ReflectionParameter::hasType

(PHP 7)

ReflectionParameter::hasTypeChecks if parameter has a type

説明

public bool ReflectionParameter::hasType ( void )

Checks if the parameter has a type associated with it.

パラメータ

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

返り値

TRUE if a type is specified, FALSE otherwise.

例1 ReflectionParameter::hasType() example

<?php
function 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)

参考


忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「ReflectionParameter::hasType - Checks if parameter has a type」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | ReflectionParameter::hasType - Checks if parameter has a type」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: