Skip to content

Commit 24c3fc2

Browse files
committed
minor #19914 [PropertyAccess] implement __isset() together with __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()
2 parents 81ca5c2 + b38c05e commit 24c3fc2

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)