Skip to content

Commit

Permalink
implement __isset() together with __get()
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed May 24, 2024
1 parent 5961ea1 commit b38c05e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/property_access.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b38c05e

Please sign in to comment.