Skip to content

Commit 4c52d4e

Browse files
committed
Document isReadable/getValue with
1 parent 17dd392 commit 4c52d4e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

components/property_access/introduction.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ method. This is done using the index notation that is used in PHP::
4646
var_dump($accessor->getValue($person, '[first_name]')); // 'Wouter'
4747
var_dump($accessor->getValue($person, '[age]')); // null
4848

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)``.
5055

5156
You can also use multi dimensional arrays::
5257

@@ -321,6 +326,13 @@ instead::
321326
// ...
322327
}
323328

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+
324336
The same is possible for :method:`PropertyAccessor::setValue<Symfony\\Component\\PropertyAccess\\PropertyAccessor::setValue>`:
325337
Call the
326338
:method:`PropertyAccessor::isWritable<Symfony\\Component\\PropertyAccess\\PropertyAccessor::isWritable>`

0 commit comments

Comments
 (0)