File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -479,6 +479,38 @@ with the ``property_info`` service in the Symfony Framework::
479479 // Type information.
480480 $doctrineExtractor->getTypes($class, $property);
481481
482+ ConstructorExtractor
483+ ~~~~~~~~~~~~~~~~~~~~
484+
485+ The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ConstructorExtractor `
486+ tries to extract properties information by using either the
487+ :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ PhpStanExtractor ` or
488+ the :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ReflectionExtractor `
489+ on the constructor arguments::
490+
491+ // src/Domain/Foo.php
492+ class Foo
493+ {
494+ private $bar;
495+
496+ public function __construct(string $bar)
497+ {
498+ $this->bar = $bar;
499+ }
500+ }
501+
502+ // Extraction.php
503+ use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
504+ use App\Domain\Foo;
505+
506+ $constructorExtractor = new ConstructorExtractor([new ReflectionExtractor()]);
507+ $constructorExtractor->getTypes(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string'
508+
509+ .. versionadded :: 5.2
510+
511+ The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ConstructorExtractor `
512+ was introduced in Symfony 5.2.
513+
482514.. _`components-property-information-extractors-creation` :
483515
484516Creating Your Own Extractors
You can’t perform that action at this time.
0 commit comments