Skip to content

Commit 90d1b48

Browse files
[PropertyInfo] Add ConstructorExtractor documentation
1 parent 271e4dc commit 90d1b48

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

components/property_info.rst

+30
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,36 @@ with the ``property_info`` service in the Symfony Framework::
483483
// Type information.
484484
$doctrineExtractor->getTypes($class, $property);
485485

486+
ConstructorExtractor
487+
~~~~~~~~~~~~~~~~~~~~
488+
489+
The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\ConstructorExtractor`
490+
tries to extract properties information from the PhpDoc present
491+
on the constructor, or by using reflection on constructor's arguments::
492+
493+
// src/Domain/Foo.php
494+
class Foo
495+
{
496+
private $bar;
497+
498+
public function __construct(string $bar)
499+
{
500+
$this->bar = $bar;
501+
}
502+
}
503+
504+
// Extraction.php
505+
use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
506+
use App\Domain\Foo;
507+
508+
$constructorExtractor = new ConstructorExtractor();
509+
$constructorExtractor->getTypes(Foo::class, 'bar');
510+
511+
.. versionadded:: 5.2
512+
513+
The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\ConstructorExtractor`
514+
was introduced in Symfony 5.2.
515+
486516
.. _`components-property-information-extractors-creation`:
487517

488518
Creating Your Own Extractors

0 commit comments

Comments
 (0)