ReflectionType::__toString
(PHP 7)
ReflectionType::__toString — To string
警告
この関数は PHP 7.1.0 で 非推奨になります。この関数に頼らないことを強く推奨します。
説明
public ReflectionType::__toString
( void
) : string
Gets the parameter type name.
パラメータ
この関数にはパラメータはありません。
返り値
Returns the type of the parameter.
例
例1 ReflectionType::__toString() example
<?php
function someFunction(string $param) {}
$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParam = $reflectionFunc->getParameters()[0];
echo $reflectionParam->getType();
上の例の出力は、 たとえば以下のようになります。
string
参考
- ReflectionNamedType::getName() - Get the text of the type hint
- ReflectionType::allowsNull() - Checks if null is allowed
- ReflectionType::isBuiltin() - Checks if it is a built-in type
- ReflectionParameter::getType() - Gets a parameter's type