Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf6db230

Browse files
[PropertyInfo] Add PhpStan extractor to PropertyInfo available extractors
1 parent2b55713 commitf6db230

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

‎components/property_info.rst‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,37 @@ library is present::
411411
$phpDocExtractor->getShortDescription($class, $property);
412412
$phpDocExtractor->getLongDescription($class, $property);
413413

414+
PhpStanExtractor
415+
~~~~~~~~~~~~~~~
416+
417+
..note::
418+
419+
This extractor depends on the `phpstan/phpdoc-parser`_ and
420+
`phpdocumentor/reflection-docblock`_ libraries.
421+
422+
This extractor fetches informations thanks to the PHPStan parser. It gathers
423+
information from annotations of properties and methods, such as ``@var``,
424+
``@param`` or ``@return``::
425+
426+
// src/Domain/Foo.php
427+
class Foo
428+
{
429+
private $bar;
430+
431+
/**
432+
* @param string $bar
433+
*/
434+
public function __construct($bar) {
435+
$this->bar = $bar;
436+
}
437+
}
438+
439+
// Extraction.php
440+
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
441+
442+
$phpStanExtractor = new PhpStanExtractor();
443+
$phpStanExtractor->getTypesFromConstructor(Foo::class, 'bar');
444+
414445
SerializerExtractor
415446
~~~~~~~~~~~~~~~~~~~
416447

@@ -436,14 +467,14 @@ with the ``property_info`` service in the Symfony Framework::
436467

437468
// the `serializer_groups` option must be configured (may be set to null)
438469
$serializerExtractor->getProperties($class, ['serializer_groups' => ['mygroup']]);
439-
470+
440471
If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be
441472
checked but you will get only the properties considered by the Serializer
442473
Component (notably the ``@Ignore`` annotation is taken into account).
443474

444475
..versionadded::5.2
445476

446-
Support for the ``null`` value in ``serializer_groups`` was introduced in Symfony 5.2.
477+
Support for the ``null`` value in ``serializer_groups`` was introduced in Symfony 5.2.
447478

448479
DoctrineExtractor
449480
~~~~~~~~~~~~~~~~~
@@ -501,6 +532,7 @@ service by defining it as a service with one or more of the following
501532

502533
.. _`phpDocumentor Reflection`:https://github.com/phpDocumentor/ReflectionDocBlock
503534
.. _`phpdocumentor/reflection-docblock`:https://packagist.org/packages/phpdocumentor/reflection-docblock
535+
.. _`phpstan/phpdoc-parser`:https://packagist.org/packages/phpstan/phpdoc-parser
504536
.. _`Doctrine ORM`:https://www.doctrine-project.org/projects/orm.html
505537
.. _`symfony/serializer`:https://packagist.org/packages/symfony/serializer
506538
.. _`symfony/doctrine-bridge`:https://packagist.org/packages/symfony/doctrine-bridge

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp