ReflectionType::__toString

(PHP 7)
To string
public string ReflectionType::__toString ( void )

Gets the parameter type name.

Returns:

Returns the type of the parameter.

Examples:
ReflectionType::__toString() example
1
2
3
4
5
6
7
<?php
function someFunction(string $param) {}
 
$reflectionFunc new ReflectionFunction('someFunction');
$reflectionParam $reflectionFunc->getParameters()[0];
 
echo $reflectionParam->getType();

The above example will output something similar to:

string
See also:

ReflectionType::allowsNull() -

ReflectionType::isBuiltin() -

ReflectionParameter::getType() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.