1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Examine arrays in unknown function calls

This commit is contained in:
Matthew Brown 2019-03-27 22:13:06 -04:00
parent b7472c62c2
commit e9afd3a6f3
2 changed files with 13 additions and 0 deletions

View File

@ -383,6 +383,7 @@ class CallAnalyzer
|| $arg->value instanceof PhpParser\Node\Expr\FuncCall
|| $arg->value instanceof PhpParser\Node\Expr\MethodCall
|| $arg->value instanceof PhpParser\Node\Expr\Assign
|| $arg->value instanceof PhpParser\Node\Expr\Array_
)
) {
if (self::handleByRefFunctionArg(
@ -461,6 +462,7 @@ class CallAnalyzer
|| $arg->value instanceof PhpParser\Node\Expr\MethodCall
|| $arg->value instanceof PhpParser\Node\Expr\Assign
|| $arg->value instanceof PhpParser\Node\Expr\ArrayDimFetch
|| $arg->value instanceof PhpParser\Node\Expr\Array_
) {
if (ExpressionAnalyzer::analyze($statements_analyzer, $arg->value, $context) === false) {
return false;

View File

@ -901,6 +901,17 @@ class UnusedVariableTest extends TestCase
return (int) $_SESSION["str"];
}',
],
'usedInArray' => [
'<?php
/**
* @psalm-suppress MixedMethodCall
* @psalm-suppress MissingParamType
*/
function foo($a) : void {
$b = "b";
$a->bar([$b]);
}',
],
];
}