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

ReflectionParameter::getType - Gets a parameter's type | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

ReflectionParameter::getType

(PHP 7)

ReflectionParameter::getTypeGets a parameter's type

説明

public ReflectionType ReflectionParameter::getType ( void )

Gets the associated type of a parameter.

パラメータ

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

返り値

Returns a ReflectionType object if a parameter type is specified, NULL otherwise.

例1 ReflectionParameter::getType() example

<?php
function someFunction(int $param$param2) {}

$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParams $reflectionFunc->getParameters();
$reflectionType1 $reflectionParams[0]->getType();
$reflectionType2 $reflectionParams[1]->getType();

echo 
$reflectionType1;
var_dump($reflectionType2);

上の例の出力は、 たとえば以下のようになります。

int
null

参考


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

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