diff --git a/components/property_info.rst b/components/property_info.rst index dfd22c9d2b3..5a90e0cbc55 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -411,6 +411,38 @@ library is present:: $phpDocExtractor->getShortDescription($class, $property); $phpDocExtractor->getLongDescription($class, $property); +PhpStanExtractor +~~~~~~~~~~~~~~~ + +.. note:: + + This extractor depends on the `phpstan/phpdoc-parser`_ and + `phpdocumentor/reflection-docblock`_ libraries. + +This extractor fetches informations thanks to the PHPStan parser. This +extractor gather information from annotations of the comment section +of properties and methods, such as ``@var``, ``@param`` or ``@return``. +Like ``PhpDocExtractor``, this extractor is also compatible with promoted +constructor properties introduced in PHP 8.0:: + + // Foo.php + class Foo + { + /** + * @param string $bar + */ + public function __construct( + private string $bar = 'baz' + ) { + } + } + + // Extraction.php + use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor; + + $phpStanExtractor = new PhpStanExtractor(); + $phpStanExtractor->getTypesFromConstructor(Foo::class, 'bar'); + SerializerExtractor ~~~~~~~~~~~~~~~~~~~ @@ -436,7 +468,7 @@ with the ``property_info`` service in the Symfony Framework:: // the `serializer_groups` option must be configured (may be set to null) $serializerExtractor->getProperties($class, ['serializer_groups' => ['mygroup']]); - + If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be checked but you will get only the properties considered by the Serializer Component (notably the ``@Ignore`` annotation is taken into account). @@ -497,6 +529,7 @@ service by defining it as a service with one or more of the following .. _`phpDocumentor Reflection`: https://github.com/phpDocumentor/ReflectionDocBlock .. _`phpdocumentor/reflection-docblock`: https://packagist.org/packages/phpdocumentor/reflection-docblock +.. _`phpstan/phpdoc-parser`: https://packagist.org/packages/phpstan/phpdoc-parser .. _`Doctrine ORM`: https://www.doctrine-project.org/projects/orm.html .. _`symfony/serializer`: https://packagist.org/packages/symfony/serializer .. _`symfony/doctrine-bridge`: https://packagist.org/packages/symfony/doctrine-bridge