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"; }

preferences:
40.87 ms | 580 KiB | 5 Q