Skip to content

Commit

Permalink
Default to using inferred type unless in late static binding context.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrolGenhald committed Dec 13, 2021
1 parent 0f899ac commit 1d3dfe9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/ClassLikes.php
Expand Up @@ -1635,7 +1635,7 @@ public function getClassConstantType(
int $visibility,
?StatementsAnalyzer $statements_analyzer = null,
array $visited_constant_ids = [],
bool $late_static_binding = true
bool $late_static_binding = false
): ?Type\Union {
$class_name = strtolower($class_name);

Expand Down
3 changes: 3 additions & 0 deletions tests/ConstantTest.php
Expand Up @@ -304,14 +304,17 @@ function foo(array $arg): void {}
'lateConstantResolutionParentStringConcat' => [
'<?php
class A {
/** @var non-empty-string */
public const STR = "a";
}
class B extends A {
/** @var non-empty-string */
public const STR = parent::STR . "b";
}
class C extends B {
/** @var non-empty-string */
public const STR = parent::STR . "c";
}
Expand Down

0 comments on commit 1d3dfe9

Please sign in to comment.