1
0
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:
Brown 2019-08-15 10:41:24 -04:00
parent 3e549e275b
commit 538abbc54c
2 changed files with 12 additions and 1 deletions

View File

@ -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 {

View File

@ -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));
}
}'
],
];
}