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:
parent
5b4ed6b516
commit
3243819f1b
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user