44
55namespace TypeLang \Mapper \Type \Builder ;
66
7+ use TypeLang \Mapper \Context \BuildingContext ;
78use TypeLang \Mapper \Exception \Definition \Shape \ShapeFieldsNotSupportedException ;
89use TypeLang \Mapper \Exception \Definition \Template \Hint \TemplateArgumentHintNotSupportedException ;
910use TypeLang \Mapper \Exception \Definition \Template \TooManyTemplateArgumentsInRangeException ;
1011use TypeLang \Mapper \Exception \Definition \TypeNotFoundException ;
1112use TypeLang \Mapper \Type \ListType ;
12- use TypeLang \Mapper \Type \Parser \TypeParserInterface ;
13- use TypeLang \Mapper \Type \Repository \TypeRepositoryInterface ;
1413use TypeLang \Mapper \Type \TypeInterface ;
1514use TypeLang \Parser \Node \Stmt \NamedTypeNode ;
1615use TypeLang \Parser \Node \Stmt \Template \TemplateArgumentNode ;
@@ -44,11 +43,8 @@ public function __construct(
4443 * @throws TypeNotFoundException
4544 * @throws \Throwable
4645 */
47- public function build (
48- TypeStatement $ statement ,
49- TypeRepositoryInterface $ types ,
50- TypeParserInterface $ parser ,
51- ): TypeInterface {
46+ public function build (TypeStatement $ statement , BuildingContext $ context ): TypeInterface
47+ {
5248 /** @phpstan-ignore-next-line : Additional DbC assertion */
5349 assert ($ statement instanceof NamedTypeNode);
5450
@@ -57,8 +53,8 @@ public function build(
5753 $ arguments = $ statement ->arguments ->items ?? [];
5854
5955 return match (\count ($ arguments )) {
60- 0 => $ this ->buildWithNoValue ($ types , $ parser ),
61- 1 => $ this ->buildWithValue ($ statement , $ types ),
56+ 0 => $ this ->buildWithNoValue ($ context ),
57+ 1 => $ this ->buildWithValue ($ statement , $ context ),
6258 default => throw TooManyTemplateArgumentsInRangeException::becauseArgumentsCountRequired (
6359 minArgumentsCount: 0 ,
6460 maxArgumentsCount: 1 ,
@@ -71,13 +67,11 @@ public function build(
7167 * @throws TypeNotFoundException
7268 * @throws \Throwable
7369 */
74- private function buildWithNoValue (TypeRepositoryInterface $ types , TypeParserInterface $ parser ): TypeInterface
70+ private function buildWithNoValue (BuildingContext $ context ): TypeInterface
7571 {
7672 return new ListType (
77- value: $ types ->getTypeByStatement (
78- statement: $ parser ->getStatementByDefinition (
79- definition: $ this ->defaultValueType ,
80- ),
73+ value: $ context ->getTypeByDefinition (
74+ definition: $ this ->defaultValueType ,
8175 ),
8276 );
8377 }
@@ -87,7 +81,7 @@ private function buildWithNoValue(TypeRepositoryInterface $types, TypeParserInte
8781 * @throws TypeNotFoundException
8882 * @throws \Throwable
8983 */
90- private function buildWithValue (NamedTypeNode $ statement , TypeRepositoryInterface $ types ): TypeInterface
84+ private function buildWithValue (NamedTypeNode $ statement , BuildingContext $ context ): TypeInterface
9185 {
9286 $ arguments = $ statement ->arguments ->items ?? [];
9387
@@ -99,7 +93,7 @@ private function buildWithValue(NamedTypeNode $statement, TypeRepositoryInterfac
9993 $ this ->expectNoTemplateArgumentHint ($ statement , $ value );
10094
10195 return new ListType (
102- value: $ types ->getTypeByStatement (
96+ value: $ context ->getTypeByStatement (
10397 statement: $ value ->value ,
10498 ),
10599 );
0 commit comments