1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #1165 - default inherited unresolved constants to mixed

This commit is contained in:
Brown 2019-01-02 13:46:46 -05:00
parent 6fc79e3534
commit 9fdf29c468
2 changed files with 37 additions and 0 deletions

View File

@ -355,6 +355,14 @@ class Populator
$storage->protected_class_constants
);
foreach ($parent_storage->public_class_constant_nodes as $name => $_) {
$storage->public_class_constants[$name] = Type::getMixed();
}
foreach ($parent_storage->protected_class_constant_nodes as $name => $_) {
$storage->protected_class_constants[$name] = Type::getMixed();
}
$storage->pseudo_property_get_types += $parent_storage->pseudo_property_get_types;
$storage->pseudo_property_set_types += $parent_storage->pseudo_property_set_types;
@ -400,6 +408,10 @@ class Populator
$parent_interface_storage->invalid_dependencies
);
foreach ($parent_interface_storage->public_class_constant_nodes as $name => $_) {
$storage->public_class_constants[$name] = Type::getMixed();
}
$parent_interfaces = array_merge($parent_interfaces, $parent_interface_storage->parent_interfaces);
$this->inheritMethodsFromParent($storage, $parent_interface_storage);
@ -441,6 +453,10 @@ class Populator
$storage->public_class_constants
);
foreach ($implemented_interface_storage->public_class_constant_nodes as $name => $_) {
$storage->public_class_constants[$name] = Type::getMixed();
}
$storage->invalid_dependencies = array_merge(
$storage->invalid_dependencies,
$implemented_interface_storage->invalid_dependencies

View File

@ -260,6 +260,27 @@ class ConstantTest extends TestCase
}
}',
],
'resolveCalculatedConstant' => [
'<?php
interface Types {
public const TWO = "two";
}
interface A {
public const TYPE_ONE = "one";
public const TYPE_TWO = Types::TWO;
}
class B implements A {
public function __construct()
{
echo self::TYPE_ONE;
echo self::TYPE_TWO;
}
}',
'assertions' => [],
'error_levels' => ['MixedArgument'],
],
];
}