16
16
use PHPStan \Reflection \InitializerExprContext ;
17
17
use PHPStan \Reflection \InitializerExprTypeResolver ;
18
18
use PHPStan \Reflection \PassedByReference ;
19
+ use PHPStan \Reflection \ReflectionProvider \ReflectionProviderProvider ;
19
20
use PHPStan \ShouldNotHappenException ;
20
21
use PHPStan \Type \FileTypeMapper ;
21
22
use PHPStan \Type \MixedType ;
@@ -50,6 +51,7 @@ public function __construct(
50
51
private FileTypeMapper $ fileTypeMapper ,
51
52
private PhpVersion $ phpVersion ,
52
53
private InitializerExprTypeResolver $ initializerExprTypeResolver ,
54
+ private ReflectionProviderProvider $ reflectionProviderProvider ,
53
55
)
54
56
{
55
57
$ this ->map = new Php8StubsMap ($ phpVersion ->getVersionId ());
@@ -392,14 +394,21 @@ private function getSignature(
392
394
$ phpDocReturnType = $ phpDoc ->getReturnTag ()->getType ();
393
395
}
394
396
}
397
+
398
+ $ classReflection = null ;
399
+ if ($ className !== null ) {
400
+ $ reflectionProvider = $ this ->reflectionProviderProvider ->getReflectionProvider ();
401
+ $ classReflection = $ reflectionProvider ->getClass ($ className );
402
+ }
403
+
395
404
$ parameters = [];
396
405
$ variadic = false ;
397
406
foreach ($ function ->getParams () as $ param ) {
398
407
$ name = $ param ->var ;
399
408
if (!$ name instanceof Variable || !is_string ($ name ->name )) {
400
409
throw new ShouldNotHappenException ();
401
410
}
402
- $ parameterType = ParserNodeTypeToPHPStanType::resolve ($ param ->type , null );
411
+ $ parameterType = ParserNodeTypeToPHPStanType::resolve ($ param ->type , $ classReflection );
403
412
$ parameters [] = new ParameterSignature (
404
413
$ name ->name ,
405
414
$ param ->default !== null || $ param ->variadic ,
@@ -417,7 +426,7 @@ private function getSignature(
417
426
$ variadic = $ variadic || $ param ->variadic ;
418
427
}
419
428
420
- $ returnType = ParserNodeTypeToPHPStanType::resolve ($ function ->getReturnType (), null );
429
+ $ returnType = ParserNodeTypeToPHPStanType::resolve ($ function ->getReturnType (), $ classReflection );
421
430
422
431
return new FunctionSignature (
423
432
$ parameters ,
0 commit comments