1717use Symfony \Component \PropertyInfo \PropertyTypeExtractorInterface ;
1818
1919/**
20+ *
2021 */
21- final class FailOverExtractor implements PropertyTypeExtractorInterface
22+ final class CombinedExtractor implements PropertyTypeExtractorInterface
2223{
23- /**
24- * @psalm-var array<string, \Symfony\Component\PropertyInfo\Type[]|null>
25- */
24+ /** @psalm-var array<string, \Symfony\Component\PropertyInfo\Type[]|null> */
2625 private $ localStorage = [];
2726
28- /**
29- * @var PropertyTypeExtractorInterface[]
30- */
31- private $ extractors ;
27+ /** @var PhpDocExtractor */
28+ private $ phpDocExtractor ;
29+
30+ /** @var ReflectionExtractor */
31+ private $ reflectionPropertyExtractor ;
3232
3333 public function __construct ()
3434 {
35- $ this ->extractors = [new PhpDocExtractor (), new ReflectionExtractor ()];
35+ $ this ->phpDocExtractor = new PhpDocExtractor ();
36+ $ this ->reflectionPropertyExtractor = new ReflectionExtractor ();
3637 }
3738
3839 /**
@@ -44,19 +45,14 @@ public function getTypes(string $class, string $property, array $context = []):
4445
4546 if (\array_key_exists ($ cacheKey , $ this ->localStorage ) === false )
4647 {
47- $ this ->localStorage [ $ cacheKey ] = null ;
48+ $ types = $ this ->phpDocExtractor -> getTypes ( $ class , $ property , $ context ) ;
4849
49- foreach ($ this -> extractors as $ extractor )
50+ if ($ types === null )
5051 {
51- $ types = $ extractor ->getTypes ($ class , $ property , $ context );
52-
53- if (null !== $ types )
54- {
55- $ this ->localStorage [$ cacheKey ] = $ types ;
56-
57- break ;
58- }
52+ $ types = $ this ->reflectionPropertyExtractor ->getTypes ($ class , $ property , $ context );
5953 }
54+
55+ $ this ->localStorage [$ cacheKey ] = $ types ;
6056 }
6157
6258 return $ this ->localStorage [$ cacheKey ];
0 commit comments