3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PropertyHooks { public ?string $backedGetOnly { get => $this->backedGetOnly; } public ?string $backedSetOnly { set (?string $value) { $this->backedSetOnly = $value; } } public ?string $backedGetAndSet { set (?string $value) { $this->backedGetAndSet = $value; } get => $this->backedGetAndSet; } } $propertyHooks = new PropertyHooks(); $reflectionProperty = new ReflectionProperty($propertyHooks, 'backedGetOnly'); $reflectionProperty->isInitialized($propertyHooks); // returns true - I would expect false // backSetOnly reports false // backedGetAndSet reports true - I would also expect false if ($reflectionProperty->isInitialized($propertyHooks)) { $reflectionProperty->getRawValue($propertyHooks); // Uncaught exception 'Error' with message Typed property PropertyHooks::$backedGetOnly must not be accessed before initialization }
Output for git.master_jit, git.master
Fatal error: Uncaught Error: Typed property PropertyHooks::$backedGetOnly must not be accessed before initialization in /in/RgWO8:33 Stack trace: #0 [internal function]: PropertyHooks->$backedGetOnly::get() #1 /in/RgWO8(33): ReflectionProperty->getRawValue(Object(PropertyHooks)) #2 {main} thrown in /in/RgWO8 on line 33
Process exited with code 255.
Output for rfc.property-hooks
Fatal error: Uncaught Error: Typed property PropertyHooks::$backedGetOnly must not be accessed before initialization in /in/RgWO8:33 Stack trace: #0 /in/RgWO8(33): ReflectionProperty->getRawValue(Object(PropertyHooks)) #1 {main} thrown in /in/RgWO8 on line 33
Process exited with code 255.

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:
136.35 ms | 1425 KiB | 7 Q