mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #2020 - allow static::CONST_NAME to have non-mixed type in final class
This commit is contained in:
parent
3e549e275b
commit
538abbc54c
@ -352,7 +352,9 @@ class ConstFetchAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($class_constants[$stmt->name->name]) && $first_part_lc !== 'static') {
|
||||
if (isset($class_constants[$stmt->name->name])
|
||||
&& ($first_part_lc !== 'static' || $class_const_storage->final)
|
||||
) {
|
||||
$stmt->inferredType = clone $class_constants[$stmt->name->name];
|
||||
$context->vars_in_scope[$const_id] = $stmt->inferredType;
|
||||
} else {
|
||||
|
@ -381,6 +381,15 @@ class ConstantTest extends TestCase
|
||||
define(__NAMESPACE__."\\cons", 0);
|
||||
cons;',
|
||||
],
|
||||
'staticConstantInsideFinalClass' => [
|
||||
'<?php
|
||||
final class A {
|
||||
public const STRING = "1,2,3";
|
||||
public static function foo(): void {
|
||||
print_r(explode(",", static::STRING));
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user