55namespace Cortex \JsonSchema \Tests \Unit \Converters ;
66
77use Cortex \JsonSchema \Types \ObjectSchema ;
8- use Cortex \JsonSchema \Converters \FromClosure ;
8+ use Cortex \JsonSchema \Converters \ClosureConverter ;
99
1010it ('can create a schema from a closure ' , function (): void {
1111 $ closure = function (string $ name , array $ fooArray , ?int $ age = null ): void {};
12- $ schema = FromClosure:: convert ( $ closure );
12+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
1313
1414 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
1515 expect ($ schema ->toArray ())->toBe ([
@@ -44,7 +44,7 @@ enum MyEnum: string
4444 }
4545
4646 $ closure = function (MyEnum $ myEnum , bool $ foo = true ): void {};
47- $ schema = FromClosure:: convert ( $ closure );
47+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
4848
4949 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
5050 expect ($ schema ->toArray ())->toBe ([
@@ -78,7 +78,7 @@ enum Status: int
7878 }
7979
8080 $ closure = function (Status $ status ): void {};
81- $ schema = FromClosure:: convert ( $ closure );
81+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
8282
8383 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
8484 expect ($ schema ->toArray ())->toBe ([
@@ -102,7 +102,7 @@ enum Status: int
102102
103103it ('can create a schema from a closure with a union type ' , function (): void {
104104 $ closure = function (int |string $ foo ): void {};
105- $ schema = FromClosure:: convert ( $ closure );
105+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
106106
107107 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
108108 expect ($ schema ->toArray ())->toBe ([
@@ -124,7 +124,7 @@ enum Status: int
124124
125125it ('can create a schema from a closure with a nullable union type ' , function (): void {
126126 $ closure = function (int |string |null $ foo ): void {};
127- $ schema = FromClosure:: convert ( $ closure );
127+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
128128
129129 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
130130 expect ($ schema ->toArray ())->toBe ([
@@ -147,7 +147,7 @@ enum Status: int
147147
148148it ('can create a schema from a closure with array type hints ' , function (): void {
149149 $ closure = function (array $ items , array $ tags = ['default ' ]): void {};
150- $ schema = FromClosure:: convert ( $ closure );
150+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
151151
152152 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
153153 expect ($ schema ->toArray ())->toBe ([
@@ -170,7 +170,7 @@ enum Status: int
170170
171171it ('can create a schema from a closure with mixed type ' , function (): void {
172172 $ closure = function (mixed $ data ): void {};
173- $ schema = FromClosure:: convert ( $ closure );
173+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
174174
175175 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
176176 expect ($ schema ->toArray ())->toBe ([
@@ -197,7 +197,7 @@ enum Status: int
197197
198198it ('can create a schema from a closure with object type ' , function (): void {
199199 $ closure = function (object $ data ): void {};
200- $ schema = FromClosure:: convert ( $ closure );
200+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
201201
202202 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
203203 expect ($ schema ->toArray ())->toBe ([
@@ -216,7 +216,7 @@ enum Status: int
216216
217217it ('can create a schema from a closure with float type ' , function (): void {
218218 $ closure = function (float $ amount = 0.0 ): void {};
219- $ schema = FromClosure:: convert ( $ closure );
219+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
220220
221221 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
222222 expect ($ schema ->toArray ())->toBe ([
@@ -240,7 +240,7 @@ enum Status: int
240240 bool $ active = true ,
241241 ): void {};
242242
243- $ schema = FromClosure:: convert ( $ closure );
243+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
244244
245245 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
246246 expect ($ schema ->toArray ())->toBe ([
@@ -277,7 +277,7 @@ enum Status: int
277277
278278it ('can create a schema from a closure with array type ' , function (): void {
279279 $ closure = function (array $ items = ['default ' ]): void {};
280- $ schema = FromClosure:: convert ( $ closure );
280+ $ schema = ( new ClosureConverter ( $ closure))-> convert ( );
281281
282282 expect ($ schema )->toBeInstanceOf (ObjectSchema::class);
283283 expect ($ schema ->toArray ())->toBe ([
0 commit comments