-
-
Notifications
You must be signed in to change notification settings - Fork 928
Closed
Labels
Milestone
Description
Bug report
it seems the generic type of a collector is loosing precision..?
Code snippet that reproduces the problem
collector
/**
* @implements Collector<CallLike, array{string, TaintType::TYPE_*, string, int}>
*/
final class SinkCollector implements Collector
{
public function getNodeType(): string
{
return CallLike::class;
}
public function processNode(Node $node, Scope $scope)
{}
}
/**
* @psalm-immutable
*/
final class TaintType
{
public const TYPE_INPUT = 'input';
public const TYPE_SQL = 'sql';
public const TYPE_HTML = 'html';
public const TYPES = [self::TYPE_INPUT, self::TYPE_SQL, self::TYPE_HTML];
}
rule
/**
* @implements Rule<CollectedDataNode>
*/
final class TaintRule implements Rule
{
public function getNodeType(): string
{
return CollectedDataNode::class;
}
public function processNode(Node $node, Scope $scope): array
{
$sinkCollectorData = $node->get(SinkCollector::class);
dumpType($sinkCollectorData);
// actual: Dumped type: array<string, array<int, array{string, string, string, int}>>
// expected Dumped type: array<string, array<int, array{string, TaintType::TYPE_*,, string, int}>>
}
}