mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Fix #4797 - sanitise assertion output of template result
This commit is contained in:
parent
50611d5b91
commit
7825a71351
@ -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) {
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user