(PHP 7)
Checks if null is allowed
public bool ReflectionType::allowsNull ( void )
Checks whether the parameter allows NULL
.
Returns:
TRUE
if NULL
is allowed, otherwise FALSE
Examples:
ReflectionType::allowsNull() example
<?php function someFunction(string $param, StdClass $param2 = null) {} $reflectionFunc = new ReflectionFunction('someFunction'); $reflectionParams = $reflectionFunc->getParameters(); var_dump($reflectionParams[0]->getType()->allowsNull()); var_dump($reflectionParams[1]->getType()->allowsNull());
The above example will output something similar to:
bool(false) bool(true)
See also:
Please login to continue.