2626use TypeLang \Mapper \Mapping \Metadata \Condition \NullConditionMetadata ;
2727use TypeLang \Mapper \Mapping \Metadata \ConditionInfo ;
2828use TypeLang \Mapper \Mapping \Metadata \ConditionMetadata ;
29+ use TypeLang \Mapper \Mapping \Metadata \ParsedTypeInfo ;
30+ use TypeLang \Mapper \Mapping \Metadata \RawTypeInfo ;
2931use TypeLang \Mapper \Mapping \Metadata \TypeInfo ;
3032use TypeLang \Mapper \Mapping \Metadata \TypeMetadata ;
3133use TypeLang \Mapper \Mapping \Reader \ReaderInterface ;
34+ use TypeLang \Mapper \Mapping \Reader \ReflectionReader ;
3235use TypeLang \Mapper \Runtime \Parser \TypeParserInterface ;
3336use TypeLang \Mapper \Runtime \Repository \TypeRepositoryInterface ;
3437
3538final class MetadataReaderProvider implements ProviderInterface
3639{
3740 public function __construct (
38- private readonly ReaderInterface $ reader ,
41+ private readonly ReaderInterface $ reader = new ReflectionReader () ,
3942 private ?ExpressionLanguage $ expression = null ,
4043 private readonly ?ClockInterface $ clock = null ,
4144 ) {}
@@ -52,9 +55,7 @@ public function getClassMetadata(
5255 TypeRepositoryInterface $ types ,
5356 TypeParserInterface $ parser ,
5457 ): ClassMetadata {
55- $ info = $ this ->reader ->read ($ class );
56-
57- dd ($ info );
58+ $ info = $ this ->reader ->read ($ class , $ parser );
5859
5960 return $ this ->toClassMetadata ($ info , $ types , $ parser );
6061 }
@@ -302,7 +303,15 @@ private function toTypeMetadata(
302303 TypeRepositoryInterface $ types ,
303304 TypeParserInterface $ parser ,
304305 ): TypeMetadata {
305- $ statement = $ parser ->getStatementByDefinition ($ info ->definition );
306+ $ statement = match (true ) {
307+ $ info instanceof RawTypeInfo => $ parser ->getStatementByDefinition ($ info ->definition ),
308+ $ info instanceof ParsedTypeInfo => $ info ->statement ,
309+ default => throw new \InvalidArgumentException (\sprintf (
310+ 'Unsupported type info "%s" ' ,
311+ $ info ::class,
312+ ))
313+ };
314+
306315 $ type = $ types ->getTypeByStatement ($ statement );
307316
308317 return new TypeMetadata (
0 commit comments