Debian Codegraph @

lib/3rdParty/composer/symfony/property-info/Extractor/ConstructorExtractor.php

raw symbols SCIP
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\PropertyInfo\Extractor;
13
14 use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
15 use Symfony\Component\TypeInfo\Type;
16
17 /**
18 * Extracts the constructor argument type using ConstructorArgumentTypeExtractorInterface implementations.
19 *
20 * @author Dmitrii Poddubnyi <[email protected]>
21 */
22 final class ConstructorExtractor implements PropertyTypeExtractorInterface
23 {
24 /**
25 * @param iterable<int, ConstructorArgumentTypeExtractorInterface> $extractors
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 * @deprecated since Symfony 7.3, use "getType" instead
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 }