8000 [#11156] Added versionadded and slightly reordered the code example · symfony/symfony-docs@98dfd5d · GitHub
[go: up one dir, main page]

Skip to content

Commit 98dfd5d

Browse files
committed
[#11156] Added versionadded and slightly reordered the code example
1 parent c95da92 commit 98dfd5d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

components/property_access.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,26 +166,32 @@ getters, this means that you can do something like this::
166166

167167
This will produce: ``He is an author``
168168

169-
Accessing a non existing property path
169+
Accessing a non Existing Property Path
170170
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171171

172-
By default a :class:`Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException` is thrown if the property path passed to :method:`PropertyAccessor::getValue<Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue>`
173-
does not exist.
174-
You can change this behaviour using the :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::disableExceptionOnInvalidPropertyPath`
172+
.. versionadded:: 4.3
173+
174+
The ``disableExceptionOnInvalidPropertyPath()`` method was introduced in
175+
Symfony 4.3.
176+
177+
By default a :class:`Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException`
178+
is thrown if the property path passed to :method:`PropertyAccessor::getValue<Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue>`
179+
does not exist. You can change this behaviour using the
180+
:method:`Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::disableExceptionOnInvalidPropertyPath`
175181
method::
176182

177183
// ...
178-
$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
179-
->disableExceptionOnInvalidPropertyPath()
180-
->getPropertyAccessor();
181-
182184
class Person
183185
{
184186
public $name;
185187
}
186188

187189
$person = new Person();
188190

191+
$propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
192+
->disableExceptionOnInvalidPropertyPath()
193+
->getPropertyAccessor();
194+
189195
// instead of throwing an exception the following code returns null
190196
$value = $propertyAccessor->getValue($person, 'birthday');
191197

0 commit comments

Comments
 (0)
0