Skip to content

Commit b38c05e

Browse files
committed
implement __isset() together with __get()
1 parent 5961ea1 commit b38c05e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/property_access.rst

+10
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,22 @@ The ``getValue()`` method can also use the magic ``__get()`` method::
204204
{
205205
return $this->children[$id];
206206
}
207+
208+
public function __isset($id): bool
209+
{
210+
return true;
211+
}
207212
}
208213

209214
$person = new Person();
210215

211216
var_dump($propertyAccessor->getValue($person, 'Wouter')); // [...]
212217

218+
.. caution::
219+
220+
When implementing the magic ``__get()`` method, you also need to implement
221+
``__isset()``.
222+
213223
.. versionadded:: 5.2
214224

215225
The magic ``__get()`` method can be disabled since in Symfony 5.2.

0 commit comments

Comments
 (0)