ReflectionType::allowsNull

(PHP 7)

ReflectionType::allowsNullChecks if null is allowed

Descripción

public ReflectionType::allowsNull ( void ) : bool

Checks whether the parameter allows NULL.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

TRUE if NULL is allowed, otherwise FALSE

Ejemplos

Ejemplo #1 ReflectionType::allowsNull() example

<?php
function someFunction(string $paramStdClass $param2 null) {}

$reflectionFunc = new ReflectionFunction('someFunction');
$reflectionParams $reflectionFunc->getParameters();

var_dump($reflectionParams[0]->getType()->allowsNull());
var_dump($reflectionParams[1]->getType()->allowsNull());

El resultado del ejemplo sería algo similar a:

bool(false)
bool(true)

Ver también