ReflectionClass::isUninitializedLazyObject

Checks if an object is lazy and uninitialized

Description

public bool ReflectionClass::isUninitializedLazyObject(object $object)

Checks if an object is lazy and uninitialized.

Parameters

object
The object to check.

Return Values

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

Examples

Example #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));
?>

The above example will output:

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

See Also

  • Lazy objects
  • ReflectionClass::newLazyGhost
  • ReflectionClass::markLazyObjectAsInitialized
  • ReflectionClass::initializeLazyObject