diff --git a/components/property_access.rst b/components/property_access.rst index e2e6cb95796..953a05bff47 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -204,12 +204,22 @@ The ``getValue()`` method can also use the magic ``__get()`` method:: { return $this->children[$id]; } + + public function __isset($id): bool + { + return true; + } } $person = new Person(); var_dump($propertyAccessor->getValue($person, 'Wouter')); // [...] +.. caution:: + + When implementing the magic ``__get()`` method, you also need to implement + ``__isset()``. + .. versionadded:: 5.2 The magic ``__get()`` method can be disabled since in Symfony 5.2.