File tree 1 file changed +32
-0
lines changed
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::
479
479
// Type information.
480
480
$doctrineExtractor->getTypes($class, $property);
481
481
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
+
482
514
.. _`components-property-information-extractors-creation` :
483
515
484
516
Creating Your Own Extractors
You can’t perform that action at this time.
0 commit comments