| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\PropertyInfo\Extractor; |
| 13 |
|
| 14 |
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; |
| 15 |
use Symfony\Component\TypeInfo\Type; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
final class ConstructorExtractor implements PropertyTypeExtractorInterface |
| 23 |
{ |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public function __construct( |
| 28 |
private readonly iterable $extractors = [], |
| 29 |
) { |
| 30 |
} |
| 31 |
|
| 32 |
public function getType(string $class, string $property, array $context = []): ?Type |
| 33 |
{ |
| 34 |
foreach ($this->extractors as $extractor) { |
| 35 |
if (null !== $value = $extractor->getTypeFromConstructor($class, $property)) { |
| 36 |
return $value; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
return null; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public function getTypes(string $class, string $property, array $context = []): ?array |
| 47 |
{ |
| 48 |
trigger_deprecation('symfony/property-info', '7.3', 'The "%s()" method is deprecated, use "%s::getType()" instead.', __METHOD__, self::class); |
| 49 |
|
| 50 |
foreach ($this->extractors as $extractor) { |
| 51 |
$value = $extractor->getTypesFromConstructor($class, $property); |
| 52 |
if (null !== $value) { |
| 53 |
return $value; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
return null; |
| 58 |
} |
| 59 |
} |