Skip to content

Commit 669b470

Browse files
committed
minor #18942 [PropertyInfo] Added documentation about camelCase assumption for getter/setter methods (jbtronics)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [PropertyInfo] Added documentation about camelCase assumption for getter/setter methods Fix #18940 With this PR, the documentation makes it more clear, that getters/setters for snake and camel case style properties can have a PSR-1 conform camelCase getter/setter to be considered accessible. Commits ------- e063877 [PropertyInfo] Added documentation about camelCase assumption for getter/setter methods
2 parents 14ad5c0 + e063877 commit 669b470

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

components/property_info.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ provide whether properties are readable or writable as booleans::
225225
The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\ReflectionExtractor` looks
226226
for getter/isser/setter/hasser method in addition to whether or not a property is public
227227
to determine if it's accessible. This based on how the :doc:`PropertyAccess </components/property_access>`
228-
works.
228+
works. It assumes camel case style method names following `PSR-1`_. Therefore, a property like ``myProperty`` or ``my_property`` is
229+
readable if it has a ``getMyProperty()`` and writable if it has a ``setMyProperty()`` method.
230+
231+
.. versionadded:: 6.4
232+
233+
Camel case style setter methods for properties in snake case (like ``my_property``) are accepted since Symfony 6.4. Before, the
234+
setter name had to contain the underscores (e.g. `setMy_property()`) to make the property assumed writable.
235+
229236

230237
.. _property-info-initializable:
231238

@@ -552,6 +559,7 @@ service by defining it as a service with one or more of the following
552559
* ``property_info.initializable_extractor`` if it provides initializable information
553560
(it checks if a property can be initialized through the constructor).
554561

562+
.. _`PSR-1`: https://www.php-fig.org/psr/psr-1/
555563
.. _`phpDocumentor Reflection`: https://github.com/phpDocumentor/ReflectionDocBlock
556564
.. _`phpdocumentor/reflection-docblock`: https://packagist.org/packages/phpdocumentor/reflection-docblock
557565
.. _`phpstan/phpdoc-parser`: https://packagist.org/packages/phpstan/phpdoc-parser

0 commit comments

Comments
 (0)