mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #1384 - evaluate array fetches even when we don’t know function
This commit is contained in:
parent
674657a51d
commit
4f770d356e
@ -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;
|
||||
|
@ -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]);
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user