isReadOnly()) { throw new InvalidArgumentException('Given property is not readonly.'); } parent::__construct($wrappedProperty->class, $wrappedProperty->name); } public function getValue(object|null $object = null): mixed { return $this->wrappedProperty->getValue(...func_get_args()); } public function setValue(mixed $objectOrValue, mixed $value = null): void { if (func_num_args() < 2 || $objectOrValue === null || ! $this->isInitialized($objectOrValue)) { $this->wrappedProperty->setValue(...func_get_args()); return; } assert(is_object($objectOrValue)); if (parent::getValue($objectOrValue) !== $value) { throw new LogicException(sprintf('Attempting to change readonly property %s::$%s.', $this->class, $this->name)); } } }