mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2977 - make MixedAssignment message a bit more clear, hopefully
This commit is contained in:
parent
c85fa9083d
commit
a8a1142889
@ -343,10 +343,20 @@ class AssignmentAnalyzer
|
||||
&& !strpos($root_var_id ?? '', '->')
|
||||
&& !$comment_type
|
||||
) {
|
||||
$assign_value_id = $assign_value
|
||||
? ExpressionAnalyzer::getArrayVarId(
|
||||
$assign_value,
|
||||
$statements_analyzer->getFQCLN(),
|
||||
$statements_analyzer
|
||||
)
|
||||
: null;
|
||||
|
||||
if (IssueBuffer::accepts(
|
||||
new MixedAssignment(
|
||||
'Cannot assign' . ($var_id ? ' ' . $var_id . ' ' : ' ') . 'to a mixed type',
|
||||
new CodeLocation($statements_analyzer->getSource(), $assign_var)
|
||||
$var_id
|
||||
? 'Unable to determine the type that ' . $var_id . ' is being assigned to'
|
||||
: 'Unable to determine the type of this assignment',
|
||||
new CodeLocation($statements_analyzer->getSource(), $assign_value ?: $assign_var)
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
)) {
|
||||
|
@ -1181,7 +1181,7 @@ class ReturnTypeTest extends TestCase
|
||||
|
||||
$res = map(function(int $i): string { return (string) $i; })([1,2,3]);
|
||||
',
|
||||
'error_message' => 'MixedAssignment - src/somefile.php:10:51 - Cannot assign $value to a mixed type',
|
||||
'error_message' => 'MixedAssignment - src/somefile.php:10:51 - Unable to determine the type that $value is being assigned to',
|
||||
],
|
||||
'cannotInferReturnClosureWithMoreSpecificTypes' => [
|
||||
'<?php
|
||||
|
Loading…
x
Reference in New Issue
Block a user