mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1165 - default inherited unresolved constants to mixed
This commit is contained in:
parent
6fc79e3534
commit
9fdf29c468
@ -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
|
||||
|
@ -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'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user