Skip to content

Commit c1d06cd

Browse files
[PropertyInfo] Add ConstructorExtractor documentation for 6.2 (with CPP)
1 parent 91bbff3 commit c1d06cd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

components/property_info.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ information from annotations of properties and methods, such as ``@var``,
442442

443443
// Extraction.php
444444
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
445+
use App\Domain\Foo;
445446

446447
$phpStanExtractor = new PhpStanExtractor();
447448
$phpStanExtractor->getTypesFromConstructor(Foo::class, 'bar');
@@ -509,6 +510,28 @@ with the ``property_info`` service in the Symfony Framework::
509510
// Type information.
510511
$doctrineExtractor->getTypes($class, $property);
511512

513+
ConstructorExtractor
514+
~~~~~~~~~~~~~~~~~~~~
515+
516+
The :class:`Symfony\\Component\\PropertyInfo\\Extractor\\ConstructorExtractor`
517+
tries to extract properties information from the PhpDoc present
518+
on the constructor, or by using reflection on constructor's arguments::
519+
520+
// src/Domain/Foo.php
521+
class Foo
522+
{
523+
public function __construct(private string $bar)
524+
{
525+
}
526+
}
527+
528+
// Extraction.php
529+
use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
530+
use App\Domain\Foo;
531+
532+
$constructorExtractor = new ConstructorExtractor();
533+
$constructorExtractor->getTypes(Foo::class, 'bar');
534+
512535
.. _`components-property-information-extractors-creation`:
513536

514537
Creating Your Own Extractors

0 commit comments

Comments
 (0)