ReflectionType::allowsNull

(PHP 7)

ReflectionType::allowsNullChecks if null is allowed

Опис

public bool ReflectionType::allowsNull ( void )

Checks whether the parameter allows NULL.

Параметри

В цієї функції немає параметрів.

Значення, що повертаються

TRUE if NULL is allowed, otherwise FALSE

Приклади

Приклад #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());

Наведений вище приклад виведе щось подібне до:

bool(false)
bool(true)

Прогляньте Також

add a note add a note

User Contributed Notes

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