File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
components/property_access Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,12 @@ method. This is done using the index notation that is used in PHP::
46
46
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
47
47
var_dump($accessor->getValue($person, '[age]')); // null
48
48
49
- As you can see, the method will return ``null `` if the index does not exists.
49
+ .. caution ::
50
+
51
+ As you can see, the method will return ``null `` if the index does not exists.
52
+ To make it throws an exception in case of invalid index, set the first argument
53
+ :method: `PropertyAccess::createPropertyAccessor<Symfony\\ Component\\ PropertyAccess\\ PropertyAccess::createPropertyAccessor()> `
54
+ to true, e.g. ``PropertyAccess::createPropertyAccessor(true) ``.
50
55
51
56
You can also use multi dimensional arrays::
52
57
@@ -321,6 +326,13 @@ instead::
321
326
// ...
322
327
}
323
328
329
+ .. caution ::
330
+
331
+ Calling :method: `PropertyAccess::createPropertyAccessor<Symfony\\ Component\\ PropertyAccess\\ PropertyAccess::createPropertyAccessor()> `
332
+ with an array for an invalid index would always return ``true ``. To make it returns ``false ``, set the first argument
333
+ :method: `PropertyAccess::createPropertyAccessor<Symfony\\ Component\\ PropertyAccess\\ PropertyAccess::createPropertyAccessor()> `
334
+ to true, e.g. ``PropertyAccess::createPropertyAccessor(true) ``.
335
+
324
336
The same is possible for :method: `PropertyAccessor::setValue<Symfony\\ Component\\ PropertyAccess\\ PropertyAccessor::setValue> `:
325
337
Call the
326
338
:method: `PropertyAccessor::isWritable<Symfony\\ Component\\ PropertyAccess\\ PropertyAccessor::isWritable> `
You can’t perform that action at this time.
0 commit comments