From b5e9a1f78133672236fbae5d6a32ca15b77a03b2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 2 Feb 2018 17:19:21 +0100 Subject: [PATCH 1/2] Mention the adder/remover support of PropertyInfo --- components/property_info.rst | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index 114f9b3cb12..d297318297e 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -237,8 +237,33 @@ 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 ` -works. +to determine if it's accessible. + +This is based on how :doc:`PropertyAccess ` 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 removeFoot(Dummy $foot) + { + // ... + } + } + + $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:: From 435aa2a3904466184544f205251948a936d636da Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 19 Mar 2018 08:52:48 +0100 Subject: [PATCH 2/2] Finish the docs --- components/property_info.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/property_info.rst b/components/property_info.rst index d297318297e..5adc4f3ec54 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -253,12 +253,23 @@ and plural property names:: // ... } + 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