22
33namespace Orisai \ObjectMapper \Callbacks \Context ;
44
5- use Closure ;
5+ use Orisai \ ObjectMapper \ MappedObject ;
66use Orisai \ObjectMapper \Processing \Context \DynamicContext ;
7+ use Orisai \ObjectMapper \Processing \Context \ProcessorCallContext ;
78use Orisai \ObjectMapper \Processing \Context \PropertyContext ;
89use Orisai \ObjectMapper \Processing \Context \ServicesContext ;
910use Orisai \ObjectMapper \Types \Type ;
@@ -13,36 +14,27 @@ final class FieldContext extends CallbackBaseContext
1314
1415 private PropertyContext $ property ;
1516
16- /** @var Closure(): Type */
17- private Closure $ typeCreator ;
18-
19- private ?Type $ type = null ;
17+ /** @var ProcessorCallContext<MappedObject> */
18+ private ProcessorCallContext $ call ;
2019
2120 /**
22- * @param Closure(): Type $typeCreator
21+ * @param ProcessorCallContext<MappedObject> $call
2322 */
2423 public function __construct (
2524 ServicesContext $ services ,
2625 DynamicContext $ dynamic ,
2726 PropertyContext $ property ,
28- Closure $ typeCreator
27+ ProcessorCallContext $ call
2928 )
3029 {
3130 parent ::__construct ($ services , $ dynamic );
3231 $ this ->property = $ property ;
33- $ this ->typeCreator = $ typeCreator ;
32+ $ this ->call = $ call ;
3433 }
3534
3635 public function getType (): Type
3736 {
38- if ($ this ->type !== null ) {
39- return $ this ->type ;
40- }
41-
42- $ type = ($ this ->typeCreator )();
43- unset($ this ->typeCreator );
44-
45- return $ this ->type = $ type ;
37+ return $ this ->call ->getType ()->getField ($ this ->property ->getFieldName ());
4638 }
4739
4840 public function getPropertyName (): string
0 commit comments