1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #2358 - always analyse new XXX(...) in unknown method calls

This commit is contained in:
Brown 2019-11-18 16:14:21 -05:00
parent e76beffa78
commit 81f513bb4c
2 changed files with 16 additions and 0 deletions

View File

@ -405,6 +405,7 @@ class CallAnalyzer
|| $arg->value instanceof PhpParser\Node\Expr\FuncCall
|| $arg->value instanceof PhpParser\Node\Expr\MethodCall
|| $arg->value instanceof PhpParser\Node\Expr\StaticCall
|| $arg->value instanceof PhpParser\Node\Expr\New_
|| $arg->value instanceof PhpParser\Node\Expr\Assign
|| $arg->value instanceof PhpParser\Node\Expr\Array_
)
@ -625,6 +626,7 @@ class CallAnalyzer
|| $arg->value instanceof PhpParser\Node\Expr\FuncCall
|| $arg->value instanceof PhpParser\Node\Expr\MethodCall
|| $arg->value instanceof PhpParser\Node\Expr\StaticCall
|| $arg->value instanceof PhpParser\Node\Expr\New_
|| $arg->value instanceof PhpParser\Node\Expr\Assign
|| $arg->value instanceof PhpParser\Node\Expr\ArrayDimFetch
|| $arg->value instanceof PhpParser\Node\Expr\PropertyFetch

View File

@ -1292,6 +1292,20 @@ class UnusedVariableTest extends TestCase
echo $i;
}'
],
'usedInNewCall' => [
'<?php
/**
* @psalm-suppress MixedAssignment
* @psalm-suppress MixedMethodCall
* @psalm-suppress MissingParamType
* @psalm-suppress MixedArgument
* @psalm-suppress PossiblyNullArgument
*/
function foo($a): void {
$m = $_GET["m"] ?? null;
$a->foo(new Exception($m));
}',
],
];
}