1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Detect function in array access op

This commit is contained in:
Brown 2019-08-13 14:07:45 -04:00
parent da230bc9f1
commit 0468d11158
2 changed files with 14 additions and 4 deletions

View File

@ -721,10 +721,6 @@ class AssignmentAnalyzer
return false;
}
if (!$was_in_assignment) {
$context->inside_assignment = false;
}
$array_var_id = ExpressionAnalyzer::getArrayVarId(
$stmt->var,
$statements_analyzer->getFQCLN(),
@ -831,6 +827,10 @@ class AssignmentAnalyzer
}
}
if (!$was_in_assignment) {
$context->inside_assignment = false;
}
return null;
}

View File

@ -1046,6 +1046,16 @@ class UnusedVariableTest extends TestCase
return $last;
}'
],
'usedStrtolowerInArray' => [
'<?php
/**
* @param array<string, int> $row
*/
function foo(array $row, string $s) : array {
$row["a" . strtolower($s)] += 1;
return $row;
}',
],
];
}