mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #5518 - add type for property with variable name
This commit is contained in:
parent
daa40281df
commit
7b7354efa3
@ -204,6 +204,19 @@ class InstancePropertyFetchAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
$statements_analyzer->node_data->setType($stmt, Type::getMixed());
|
||||
|
||||
if ($codebase->store_node_types
|
||||
&& !$context->collect_initializations
|
||||
&& !$context->collect_mutations
|
||||
) {
|
||||
$codebase->analyzer->addNodeType(
|
||||
$statements_analyzer->getFilePath(),
|
||||
$stmt->name,
|
||||
$stmt_var_type->getId()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2365,6 +2365,18 @@ class UnusedVariableTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'concatWithUnknownProperty' => [
|
||||
'<?php
|
||||
/** @param array<string> $key */
|
||||
function foo(object $a, string $k) : string {
|
||||
$sortA = "";
|
||||
|
||||
/** @psalm-suppress MixedOperand */
|
||||
$sortA .= $a->$k;
|
||||
|
||||
return $sortA;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user