Skip to content

Commit

Permalink
minor #19914 [PropertyAccess] implement __isset() together with `__…
Browse files Browse the repository at this point in the history
…get()` (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[PropertyAccess] implement `__isset()` together with `__get()`

see symfony/symfony#54739 (comment)

Commits
-------

b38c05e implement __isset() together with __get()
  • Loading branch information
OskarStark committed May 24, 2024
2 parents 81ca5c2 + b38c05e commit 24c3fc2
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 24c3fc2

Please sign in to comment.