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 git.master, git.master_jit
$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

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.96 ms | 586 KiB | 4 Q