9
9
use phpDocumentor \Reflection \DocBlock \Tags \Method ;
10
10
use phpDocumentor \Reflection \DocBlock \Tags \MethodParameter ;
11
11
use phpDocumentor \Reflection \Type ;
12
+ use phpDocumentor \Reflection \TypeResolver ;
12
13
use phpDocumentor \Reflection \Types \Context ;
13
14
use phpDocumentor \Reflection \Types \Mixed_ ;
14
15
use phpDocumentor \Reflection \Types \Void_ ;
25
26
*/
26
27
final class MethodFactory implements PHPStanFactory
27
28
{
28
- private TypeFactory $ typeFactory ;
29
29
private DescriptionFactory $ descriptionFactory ;
30
+ private TypeResolver $ typeResolver ;
30
31
31
- public function __construct (TypeFactory $ typeFactory , DescriptionFactory $ descriptionFactory )
32
+ public function __construct (TypeResolver $ typeResolver , DescriptionFactory $ descriptionFactory )
32
33
{
33
- $ this ->typeFactory = $ typeFactory ;
34
34
$ this ->descriptionFactory = $ descriptionFactory ;
35
+ $ this ->typeResolver = $ typeResolver ;
35
36
}
36
37
37
- public function create (PhpDocTagNode $ node , ? Context $ context ): Tag
38
+ public function create (PhpDocTagNode $ node , Context $ context ): Tag
38
39
{
39
40
$ tagValue = $ node ->value ;
40
41
Assert::isInstanceOf ($ tagValue , MethodTagValueNode::class);
@@ -50,7 +51,7 @@ public function create(PhpDocTagNode $node, ?Context $context): Tag
50
51
function (MethodTagValueParameterNode $ param ) use ($ context ) {
51
52
return new MethodParameter (
52
53
trim ($ param ->parameterName , '$ ' ),
53
- $ this ->typeFactory ->createType ($ param ->type , $ context ) ?? new Mixed_ (),
54
+ $ this ->typeResolver ->createType ($ param ->type , $ context ) ?? new Mixed_ (),
54
55
$ param ->isReference ,
55
56
$ param ->isVariadic ,
56
57
(string ) $ param ->defaultValue
@@ -61,13 +62,13 @@ function (MethodTagValueParameterNode $param) use ($context) {
61
62
);
62
63
}
63
64
64
- public function supports (PhpDocTagNode $ node , ? Context $ context ): bool
65
+ public function supports (PhpDocTagNode $ node , Context $ context ): bool
65
66
{
66
67
return $ node ->value instanceof MethodTagValueNode;
67
68
}
68
69
69
- private function createReturnType (MethodTagValueNode $ tagValue , ? Context $ context ): Type
70
+ private function createReturnType (MethodTagValueNode $ tagValue , Context $ context ): Type
70
71
{
71
- return $ this ->typeFactory ->createType ($ tagValue ->returnType , $ context ) ?? new Void_ ();
72
+ return $ this ->typeResolver ->createType ($ tagValue ->returnType , $ context ) ?? new Void_ ();
72
73
}
73
74
}
0 commit comments