1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #4797 - sanitise assertion output of template result

This commit is contained in:
Matt Brown 2020-12-07 19:11:56 -05:00
parent 8a76a43d8c
commit 91ee4aeca3
2 changed files with 28 additions and 0 deletions

View File

@ -870,6 +870,16 @@ class CallAnalyzer
);
}
if ($template_type_map) {
$readonly_template_result = new TemplateResult($template_type_map, $template_type_map);
\Psalm\Internal\Type\TemplateInferredTypeReplacer::replace(
$op_vars_in_scope[$var_id],
$readonly_template_result,
$codebase
);
}
$op_vars_in_scope[$var_id]->from_docblock = true;
foreach ($op_vars_in_scope[$var_id]->getAtomicTypes() as $changed_atomic_type) {

View File

@ -904,7 +904,25 @@ class FunctionTemplateAssertTest extends TestCase
}',
'error_message' => 'RedundantCondition',
],
'dontBleedTemplateTypeInArrayAgain' => [
'<?php
/**
* @psalm-template T
* @psalm-param array<T> $array
* @psalm-assert array<string, T> $array
*/
function isMap(array $array) : void {}
/**
* @param array<string> $arr
*/
function bar(array $arr): void {
isMap($arr);
/** @psalm-trace $arr */
$arr;
}',
'error_message' => 'string, string',
],
];
}
}