ReflectionType::allowsNull

(PHP 7)

ReflectionType::allowsNullChecks if null is allowed

Opis

public ReflectionType::allowsNull ( void ) : bool

Checks whether the parameter allows NULL.

Parametry

Ta funkcja nie posiada parametrów.

Zwracane wartości

TRUE if NULL is allowed, otherwise FALSE

Przykłady

Przykład #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());

Powyższy przykład wyświetli coś podobnego do:

bool(false)
bool(true)

Zobacz też:

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top