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 @@ -505,6 +505,38 @@ with the ``property_info`` service in the Symfony Framework::
505505 // Type information.
506506 $doctrineExtractor->getTypes($class, $property);
507507
508+ ConstructorExtractor
509+ ~~~~~~~~~~~~~~~~~~~~
510+
511+ The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ConstructorExtractor `
512+ tries to extract properties information by using either the
513+ :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ PhpStanExtractor ` or
514+ the :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ReflectionExtractor `
515+ on the constructor arguments::
516+
517+ // src/Domain/Foo.php
518+ class Foo
519+ {
520+ private $bar;
521+
522+ public function __construct(string $bar)
523+ {
524+ $this->bar = $bar;
525+ }
526+ }
527+
528+ // Extraction.php
529+ use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
530+ use App\Domain\Foo;
531+
532+ $constructorExtractor = new ConstructorExtractor([new ReflectionExtractor()]);
533+ $constructorExtractor->getTypes(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string'
534+
535+ .. versionadded :: 5.2
536+
537+ The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ConstructorExtractor `
538+ was introduced in Symfony 5.2.
539+
508540.. _`components-property-information-extractors-creation` :
509541
510542Creating Your Own Extractors
You can’t perform that action at this time.
0 commit comments