3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyClass {} class OtherClass {} class SubClass extends MyClass {} $reflector = new ReflectionClass(MyClass::class); foreach( [ '$reflector->newLazyGhost(static fn() => null)', '$reflector->newLazyProxy(static fn() => null)', '$reflector->resetAsLazyGhost($m, static fn() => null)', '$reflector->resetAsLazyGhost($s, static fn() => null)', '$reflector->resetAsLazyGhost($o, static fn() => null)', '$reflector->resetAsLazyProxy($m, static fn() => null)', '$reflector->resetAsLazyProxy($s, static fn() => null)', '$reflector->resetAsLazyProxy($o, static fn() => null)', '$reflector->initializeLazyObject($o)', '$reflector->initializeLazyObject($o)', '$reflector->initializeLazyObject($o)', '$reflector->markLazyObjectAsInitialized($o)', '$reflector->markLazyObjectAsInitialized($o)', '$reflector->markLazyObjectAsInitialized($o)', '$reflector->getLazyInitializer($o)', '$reflector->getLazyInitializer($o)', '$reflector->getLazyInitializer($o)', '$reflector->isUninitializedLazyObject($o)', '$reflector->isUninitializedLazyObject($o)', '$reflector->isUninitializedLazyObject($o)', ] as $code ) { echo $code; try { $m = new MyClass(); $s = new SubClass(); $o = new OtherClass(); echo "\n RET: ". get_debug_type(eval("return $code;")); } catch(Throwable $e) { echo "\n ERR: ". get_class($e) . ': ' . $e->getMessage(); } echo "\n\n"; }
Output for 8.4.9 - 8.4.23, 8.5.6 - 8.5.8
$reflector->newLazyGhost(static fn() => null) RET: MyClass $reflector->newLazyProxy(static fn() => null) RET: MyClass $reflector->resetAsLazyGhost($m, static fn() => null) RET: null $reflector->resetAsLazyGhost($s, static fn() => null) RET: null $reflector->resetAsLazyGhost($o, static fn() => null) ERR: TypeError: ReflectionClass::resetAsLazyGhost(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->resetAsLazyProxy($m, static fn() => null) RET: null $reflector->resetAsLazyProxy($s, static fn() => null) RET: null $reflector->resetAsLazyProxy($o, static fn() => null) ERR: TypeError: ReflectionClass::resetAsLazyProxy(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->initializeLazyObject($o) ERR: TypeError: ReflectionClass::initializeLazyObject(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->initializeLazyObject($o) ERR: TypeError: ReflectionClass::initializeLazyObject(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->initializeLazyObject($o) ERR: TypeError: ReflectionClass::initializeLazyObject(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->markLazyObjectAsInitialized($o) ERR: TypeError: ReflectionClass::markLazyObjectAsInitialized(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->markLazyObjectAsInitialized($o) ERR: TypeError: ReflectionClass::markLazyObjectAsInitialized(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->markLazyObjectAsInitialized($o) ERR: TypeError: ReflectionClass::markLazyObjectAsInitialized(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->getLazyInitializer($o) ERR: TypeError: ReflectionClass::getLazyInitializer(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->getLazyInitializer($o) ERR: TypeError: ReflectionClass::getLazyInitializer(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->getLazyInitializer($o) ERR: TypeError: ReflectionClass::getLazyInitializer(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->isUninitializedLazyObject($o) ERR: TypeError: ReflectionClass::isUninitializedLazyObject(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->isUninitializedLazyObject($o) ERR: TypeError: ReflectionClass::isUninitializedLazyObject(): Argument #1 ($object) must be of type MyClass, OtherClass given $reflector->isUninitializedLazyObject($o) ERR: TypeError: ReflectionClass::isUninitializedLazyObject(): Argument #1 ($object) must be of type MyClass, OtherClass given
Output for 8.2.31 - 8.2.32, 8.3.5 - 8.3.32
$reflector->newLazyGhost(static fn() => null) ERR: Error: Call to undefined method ReflectionClass::newLazyGhost() $reflector->newLazyProxy(static fn() => null) ERR: Error: Call to undefined method ReflectionClass::newLazyProxy() $reflector->resetAsLazyGhost($m, static fn() => null) ERR: Error: Call to undefined method ReflectionClass::resetAsLazyGhost() $reflector->resetAsLazyGhost($s, static fn() => null) ERR: Error: Call to undefined method ReflectionClass::resetAsLazyGhost() $reflector->resetAsLazyGhost($o, static fn() => null) ERR: Error: Call to undefined method ReflectionClass::resetAsLazyGhost() $reflector->resetAsLazyProxy($m, static fn() => null) ERR: Error: Call to undefined method ReflectionClass::resetAsLazyProxy() $reflector->resetAsLazyProxy($s, static fn() => null) ERR: Error: Call to undefined method ReflectionClass::resetAsLazyProxy() $reflector->resetAsLazyProxy($o, static fn() => null) ERR: Error: Call to undefined method ReflectionClass::resetAsLazyProxy() $reflector->initializeLazyObject($o) ERR: Error: Call to undefined method ReflectionClass::initializeLazyObject() $reflector->initializeLazyObject($o) ERR: Error: Call to undefined method ReflectionClass::initializeLazyObject() $reflector->initializeLazyObject($o) ERR: Error: Call to undefined method ReflectionClass::initializeLazyObject() $reflector->markLazyObjectAsInitialized($o) ERR: Error: Call to undefined method ReflectionClass::markLazyObjectAsInitialized() $reflector->markLazyObjectAsInitialized($o) ERR: Error: Call to undefined method ReflectionClass::markLazyObjectAsInitialized() $reflector->markLazyObjectAsInitialized($o) ERR: Error: Call to undefined method ReflectionClass::markLazyObjectAsInitialized() $reflector->getLazyInitializer($o) ERR: Error: Call to undefined method ReflectionClass::getLazyInitializer() $reflector->getLazyInitializer($o) ERR: Error: Call to undefined method ReflectionClass::getLazyInitializer() $reflector->getLazyInitializer($o) ERR: Error: Call to undefined method ReflectionClass::getLazyInitializer() $reflector->isUninitializedLazyObject($o) ERR: Error: Call to undefined method ReflectionClass::isUninitializedLazyObject() $reflector->isUninitializedLazyObject($o) ERR: Error: Call to undefined method ReflectionClass::isUninitializedLazyObject() $reflector->isUninitializedLazyObject($o) ERR: Error: Call to undefined method ReflectionClass::isUninitializedLazyObject()

preferences:
41.85 ms | 586 KiB | 4 Q