@@ -191,6 +191,8 @@ method::
191
191
$value = $propertyAccessor->getValue($person, 'birthday');
192
192
193
193
194
+ .. _components-property-access-magic-get :
195
+
194
196
Magic ``__get() `` Method
195
197
~~~~~~~~~~~~~~~~~~~~~~~~
196
198
@@ -213,6 +215,11 @@ The ``getValue()`` method can also use the magic ``__get()`` method::
213
215
214
216
var_dump($propertyAccessor->getValue($person, 'Wouter')); // [...]
215
217
218
+ .. versionadded :: 5.2
219
+
220
+ The magic `__get ` method can be disabled since in Symfony 5.2.
221
+ see `Enable other Features `_.
222
+
216
223
.. _components-property-access-magic-call :
217
224
218
225
Magic ``__call() `` Method
@@ -273,6 +280,8 @@ also write to an array. This can be achieved using the
273
280
// or
274
281
// var_dump($person['first_name']); // 'Wouter'
275
282
283
+ .. _components-property-access-writing-to-objects :
284
+
276
285
Writing to Objects
277
286
------------------
278
287
@@ -351,6 +360,11 @@ see `Enable other Features`_::
351
360
352
361
var_dump($person->getWouter()); // [...]
353
362
363
+ .. versionadded :: 5.2
364
+
365
+ The magic `__set ` method can be disabled since in Symfony 5.2.
366
+ see `Enable other Features `_.
367
+
354
368
Writing to Array Properties
355
369
~~~~~~~~~~~~~~~~~~~~~~~~~~~
356
370
@@ -461,14 +475,20 @@ configured to enable extra features. To do that you could use the
461
475
// ...
462
476
$propertyAccessorBuilder = PropertyAccess::createPropertyAccessorBuilder();
463
477
464
- // enables magic __call
465
- $propertyAccessorBuilder->enableMagicCall();
478
+ $propertyAccessorBuilder->enableMagicCall(); // enables magic __call
479
+ $propertyAccessorBuilder->enableMagicGet(); // enables magic __get
480
+ $propertyAccessorBuilder->enableMagicSet(); // enables magic __set
481
+ $propertyAccessorBuilder->enableMagicMethods(); // enables magic __get, __set and __call
466
482
467
- // disables magic __call
468
- $propertyAccessorBuilder->disableMagicCall();
483
+ $propertyAccessorBuilder->disableMagicCall(); // enables magic __call
484
+ $propertyAccessorBuilder->disableMagicGet(); // enables magic __get
485
+ $propertyAccessorBuilder->disableMagicSet(); // enables magic __set
486
+ $propertyAccessorBuilder->disableMagicMethods(); // enables magic __get, __set and __call
469
487
470
- // checks if magic __call handling is enabled
488
+ // checks if magic __call, __get or __set handling are enabled
471
489
$propertyAccessorBuilder->isMagicCallEnabled(); // true or false
490
+ $propertyAccessorBuilder->isMagicGetEnabled(); // true or false
491
+ $propertyAccessorBuilder->isMagicSetEnabled(); // true or false
472
492
473
493
// At the end get the configured property accessor
474
494
$propertyAccessor = $propertyAccessorBuilder->getPropertyAccessor();
@@ -480,7 +500,7 @@ configured to enable extra features. To do that you could use the
480
500
481
501
Or you can pass parameters directly to the constructor (not the recommended way)::
482
502
483
- // ...
484
- $propertyAccessor = new PropertyAccessor(true); // this enables handling of magic __call
503
+ // enable handling of magic __call, __set but not __get:
504
+ $propertyAccessor = new PropertyAccessor(PropertyAccessor::MAGIC_CALL | PropertyAccessor::MAGIC_SET);
485
505
486
506
.. _The Inflector component : https://github.com/symfony/inflector
0 commit comments