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::
505
505
// Type information.
506
506
$doctrineExtractor->getTypes($class, $property);
507
507
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
+
508
540
.. _`components-property-information-extractors-creation` :
509
541
510
542
Creating Your Own Extractors
You can’t perform that action at this time.
0 commit comments