Skip to content

Commit 96038ec

Browse files
committed
minor #9195 Mention the adder/remover support of PropertyInfo (javiereguiluz)
This PR was squashed before being merged into the 3.4 branch (closes #9195). Discussion ---------- Mention the adder/remover support of PropertyInfo This fixes #7182. Commits ------- 620439a Mention the adder/remover support of PropertyInfo
2 parents 88dc3ec + 620439a commit 96038ec

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

components/property_info.rst

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,44 @@ provide whether properties are readable or writable as booleans.
237237
238238
The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor` looks
239239
for getter/isser/setter method in addition to whether or not a property is public
240-
to determine if it's accessible. This based on how the :doc:`PropertyAccess </components/property_access>`
241-
works.
240+
to determine if it's accessible.
241+
242+
This is based on how :doc:`PropertyAccess </components/property_access>` works,
243+
so it even looks for in adder/remover methods and can transform between singular
244+
and plural property names::
245+
246+
class SomeClass
247+
{
248+
private $analyses;
249+
private $feet;
250+
251+
public function addAnalyse(Dummy $analyse)
252+
{
253+
// ...
254+
}
255+
256+
public function removeAnalyse(Dummy $analyse)
257+
{
258+
// ...
259+
}
260+
261+
public function addFoot(Dummy $foot)
262+
{
263+
// ...
264+
}
265+
266+
public function removeFoot(Dummy $foot)
267+
{
268+
// ...
269+
}
270+
}
271+
272+
// to be writable, both the adder and the remover methods must be defined
273+
$propertyInfo->isWritable(SomeClass::class, 'analyses'); // returns true
274+
$propertyInfo->isWritable(SomeClass::class, 'feet'); // returns true
275+
276+
.. versionadded:: 3.2
277+
The support of adder/remover methods was introduced in Symfony 3.2.
242278

243279
.. tip::
244280

0 commit comments

Comments
 (0)