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 8.1.0 - 8.1.29, 8.2.0 - 8.2.23, 8.3.0 - 8.3.11
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/RgWO8 on line 5
Process exited with code 255.

preferences:
153.16 ms | 1425 KiB | 7 Q