1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #2941 - allow class-string<self> to be fleshed out

This commit is contained in:
Matthew Brown 2020-03-09 01:29:16 -04:00
parent 5b4ed6b516
commit 3243819f1b
2 changed files with 32 additions and 0 deletions

View File

@ -1302,6 +1302,21 @@ class ExpressionAnalyzer
}
}
if ($return_type instanceof Type\Atomic\TClassString
&& $return_type->as_type
) {
self::fleshOutAtomicType(
$codebase,
$return_type->as_type,
$self_class,
$static_class_type,
$parent_class,
$evaluate
);
$return_type->as = $return_type->as_type->value;
}
if ($return_type instanceof Type\Atomic\TScalarClassConstant) {
if ($return_type->fq_classlike_name === 'self' && $self_class) {
$return_type->fq_classlike_name = $self_class;

View File

@ -678,6 +678,23 @@ class ClassStringTest extends TestCase
}
}',
],
'selfResolvedOnStaticProperty' => [
'<?php
namespace Bar;
class Foo {
/** @var class-string<self> */
private static $c;
/**
* @return class-string<self>
*/
public static function r() : string
{
return self::$c;
}
}'
],
];
}