(PHP 7)
ReflectionParameter::hasType — Checks if parameter has a type
public ReflectionParameter::hasType ( ) : bool
Checks if the parameter has a type associated with it.
This function has no parameters.
true
if a type is specified, false
otherwise.
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)
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/reflectionparameter.hastype.php