1111use TypeLang \Mapper \Mapping \Metadata \ClassMetadata ;
1212use TypeLang \Mapper \Mapping \Metadata \TypeMetadata ;
1313use TypeLang \Mapper \Mapping \SkipWhen ;
14- use TypeLang \Mapper \Runtime \Repository \TypeRepository ;
14+ use TypeLang \Mapper \Runtime \Parser \TypeParserInterface ;
15+ use TypeLang \Mapper \Runtime \Repository \TypeRepositoryInterface ;
1516
1617final class AttributeDriver extends LoadableDriver
1718{
1819 #[\Override]
19- protected function load (\ReflectionClass $ reflection , ClassMetadata $ class , TypeRepository $ types ): void
20- {
20+ protected function load (
21+ \ReflectionClass $ reflection ,
22+ ClassMetadata $ class ,
23+ TypeRepositoryInterface $ types ,
24+ TypeParserInterface $ parser ,
25+ ): void {
2126 foreach ($ reflection ->getProperties () as $ property ) {
2227 $ metadata = $ class ->getPropertyOrCreate ($ property ->getName ());
2328
@@ -28,7 +33,7 @@ protected function load(\ReflectionClass $reflection, ClassMetadata $class, Type
2833 $ attribute = $ this ->findPropertyAttribute ($ property , MapType::class);
2934
3035 if ($ attribute !== null ) {
31- $ type = $ this ->createType ($ attribute ->type , $ property , $ types );
36+ $ type = $ this ->createType ($ attribute ->type , $ property , $ types, $ parser );
3237
3338 $ metadata ->setTypeInfo ($ type );
3439 }
@@ -50,7 +55,7 @@ protected function load(\ReflectionClass $reflection, ClassMetadata $class, Type
5055 $ attribute = $ this ->findPropertyAttribute ($ property , SkipWhen::class);
5156
5257 if ($ attribute !== null ) {
53- $ type = $ this ->createType ($ attribute ->type , $ property , $ types );
58+ $ type = $ this ->createType ($ attribute ->type , $ property , $ types, $ parser );
5459
5560 $ metadata ->setSkipCondition ($ type );
5661 }
@@ -63,9 +68,13 @@ protected function load(\ReflectionClass $reflection, ClassMetadata $class, Type
6368 * @throws PropertyTypeNotFoundException
6469 * @throws \Throwable
6570 */
66- private function createType (string $ type , \ReflectionProperty $ property , TypeRepository $ types ): TypeMetadata
67- {
68- $ statement = $ types ->getStatementByType ($ type );
71+ private function createType (
72+ string $ type ,
73+ \ReflectionProperty $ property ,
74+ TypeRepositoryInterface $ types ,
75+ TypeParserInterface $ parser ,
76+ ): TypeMetadata {
77+ $ statement = $ parser ->getStatementByType ($ type );
6978
7079 $ class = $ property ->getDeclaringClass ();
7180
0 commit comments