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

Fix #1384 - evaluate array fetches even when we don’t know function

This commit is contained in:
Matthew Brown 2019-02-24 09:58:11 -05:00
parent 674657a51d
commit 4f770d356e
2 changed files with 12 additions and 0 deletions

View File

@ -422,6 +422,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\ArrayDimFetch
) {
if (ExpressionAnalyzer::analyze($statements_analyzer, $arg->value, $context) === false) {
return false;

View File

@ -866,6 +866,17 @@ class UnusedVariableTest extends TestCase
};
foo($listener);',
],
'newVariableConstructor' => [
'<?php
/**
* @param class-string<ArrayObject> $type
*/
function bar(string $type) : ArrayObject {
$data = [["foo"], ["bar"]];
return new $type($data[0]);
}',
],
];
}