mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Uses by ref should be assigned that way
This commit is contained in:
parent
4c1cf37d52
commit
57125c7106
@ -160,6 +160,10 @@ class ClosureAnalyzer extends FunctionLikeAnalyzer
|
||||
? clone $context->vars_in_scope[$use_var_id]
|
||||
: Type::getMixed();
|
||||
|
||||
if ($use->byRef) {
|
||||
$use_context->vars_in_scope[$use_var_id]->by_ref = true;
|
||||
}
|
||||
|
||||
$use_context->vars_possibly_in_scope[$use_var_id] = true;
|
||||
|
||||
foreach ($context->vars_in_scope as $var_id => $type) {
|
||||
|
@ -2236,6 +2236,25 @@ class UnusedVariableTest extends TestCase
|
||||
return $b;
|
||||
}'
|
||||
],
|
||||
'allowUseByRef' => [
|
||||
'<?php
|
||||
/**
|
||||
* @psalm-suppress MixedReturnStatement
|
||||
* @psalm-suppress MixedInferredReturnType
|
||||
*/
|
||||
function foo(array $data) : array {
|
||||
$output = [];
|
||||
|
||||
array_map(
|
||||
function (array $row) use (&$output) {
|
||||
$output = $row;
|
||||
},
|
||||
$data
|
||||
);
|
||||
|
||||
return $output;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user