mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #4107 - resolve reference to static in class constant
This commit is contained in:
parent
cc7ff94f7c
commit
78ed9404cb
@ -188,6 +188,10 @@ class TypeExpander
|
||||
$return_type->fq_classlike_name = $self_class;
|
||||
}
|
||||
|
||||
if ($return_type->fq_classlike_name === 'static' && $self_class) {
|
||||
$return_type->fq_classlike_name = is_string($static_class_type) ? $static_class_type : $self_class;
|
||||
}
|
||||
|
||||
if ($evaluate_class_constants && $codebase->classOrInterfaceOrEnumExists($return_type->fq_classlike_name)) {
|
||||
if (strtolower($return_type->const_name) === 'class') {
|
||||
return new Type\Atomic\TLiteralClassString($return_type->fq_classlike_name);
|
||||
|
@ -1033,7 +1033,19 @@ class ConstantTest extends TestCase
|
||||
'$dir===' => 'non-empty-string',
|
||||
'$file===' => 'non-empty-string',
|
||||
]
|
||||
]
|
||||
],
|
||||
'noCrashWithStaticInDocblock' => [
|
||||
'<?php
|
||||
class Test {
|
||||
const CONST1 = 1;
|
||||
|
||||
public function test(): void
|
||||
{
|
||||
/** @var static::CONST1 */
|
||||
$a = static::CONST1;
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user