Skip to content

Mention the adder/remover support of PropertyInfo #9195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions components/property_info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,44 @@ provide whether properties are readable or writable as booleans.

The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor` looks
for getter/isser/setter method in addition to whether or not a property is public
to determine if it's accessible. This based on how the :doc:`PropertyAccess </components/property_access>`
works.
to determine if it's accessible.

This is based on how :doc:`PropertyAccess </components/property_access>` works,
so it even looks for in adder/remover methods and can transform between singular
and plural property names::

class SomeClass
{
private $analyses;
private $feet;

public function addAnalyse(Dummy $analyse)
{
// ...
}

public function removeAnalyse(Dummy $analyse)
{
// ...
}

public function addFoot(Dummy $foot)
{
// ...
}

public function removeFoot(Dummy $foot)
{
// ...
}
}

// to be writable, both the adder and the remover methods must be defined
$propertyInfo->isWritable(SomeClass::class, 'analyses'); // returns true
$propertyInfo->isWritable(SomeClass::class, 'feet'); // returns true

.. versionadded:: 3.2
The support of adder/remover methods was introduced in Symfony 3.2.

.. tip::

Expand Down