ReflectionParameter::hasType
(PHP 7, PHP 8)
ReflectionParameter::hasType — Checks if parameter has a type
Description
Checks if the parameter has a type associated with it.
Parameters
This function has no parameters.
Examples
Example #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());The above example will output something similar to:
bool(true) bool(false)
See Also
- ReflectionParameter::getType() - Gets a parameter's type
↑ and ↓ to navigate • Enter to select • Esc to close • / to open