PHP 8.4.1 Released!

ReflectionClass::isUninitializedLazyObject

(PHP 8 >= 8.4.0)

ReflectionClass::isUninitializedLazyObjectChecks if an object is lazy and uninitialized

Опис

public ReflectionClass::isUninitializedLazyObject(object $object): bool

Checks if an object is lazy and uninitialized.

Параметри

object
The object to check.

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

Returns true if object is an uninitialized lazy object, false otherwise.

Приклади

Приклад #1 Basic usage

<?php
class Example
{
public function
__construct(public int $prop) {
}
}

$reflector = new ReflectionClass(Example::class);

$object = $reflector->newLazyGhost(function ($object) {
echo
"Initializer called\n";
$object->__construct(1);
});

var_dump($reflector->isUninitializedLazyObject($object));

var_dump($object->prop);

var_dump($reflector->isUninitializedLazyObject($object));
?>

Поданий вище приклад виведе:

bool(true)
Initializer called
int(1)
bool(false)

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

add a note

User Contributed Notes

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