ReflectionType::__toString
PHP function
Edit on GitHub ✎
(PHP 7, PHP 8)
To string
Description
ReflectionType::__toString(): string
Gets the parameter type name.
Parameters Parameters
Return Values
Returns the type of the parameter.
Changelog
| Version | Description |
|---|---|
| 8.0.0 | ReflectionType::__toString has been undeprecated. |
| 7.1.0 | ReflectionType::__toString has been deprecated. |
Examples
ReflectionType::__toString example
php
<?php
function someFunction(string $param) {}
$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParam = $reflectionFunc->getParameters()[0];
echo $reflectionParam->getType();The above example will output something similar to:
output
stringSee Also
ReflectionNamedType::getNameReflectionNamedType::isBuiltinReflectionType::allowsNullReflectionUnionType::getTypesReflectionParameter::getType