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 @@ -483,6 +483,38 @@ with the ``property_info`` service in the Symfony Framework::
483
483
// Type information.
484
484
$doctrineExtractor->getTypes($class, $property);
485
485
486
+ ConstructorExtractor
487
+ ~~~~~~~~~~~~~~~~~~~~
488
+
489
+ The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ConstructorExtractor `
490
+ tries to extract properties information by using either the
491
+ :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ PhpStanExtractor ` or
492
+ the :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ReflectionExtractor `
493
+ on the constructor arguments::
494
+
495
+ // src/Domain/Foo.php
496
+ class Foo
497
+ {
498
+ private $bar;
499
+
500
+ public function __construct(string $bar)
501
+ {
502
+ $this->bar = $bar;
503
+ }
504
+ }
505
+
506
+ // Extraction.php
507
+ use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
508
+ use App\Domain\Foo;
509
+
510
+ $constructorExtractor = new ConstructorExtractor([new ReflectionExtractor()]);
511
+ $constructorExtractor->getTypes(Foo::class, 'bar')[0]->getBuiltinType(); // returns 'string'
512
+
513
+ .. versionadded :: 5.2
514
+
515
+ The :class: `Symfony\\ Component\\ PropertyInfo\\ Extractor\\ ConstructorExtractor `
516
+ was introduced in Symfony 5.2.
517
+
486
518
.. _`components-property-information-extractors-creation` :
487
519
488
520
Creating Your Own Extractors
You can’t perform that action at this time.
0 commit comments