<?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 } else { echo 'not initialized'; }
You have javascript disabled. You will not be able to edit any code.