Skip to content
Permalink
Browse files

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

  • Loading branch information
muglug committed Nov 18, 2019
1 parent e76beff commit 81f513bb4c72a8d3419d8123c989cb58ddae8c16
Showing with 16 additions and 0 deletions.
  1. +2 −0 src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
  2. +14 −0 tests/UnusedVariableTest.php
@@ -405,6 +405,7 @@ protected static function checkFunctionArguments(
|| $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 @@ private static function evaluateAribitraryParam(
|| $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
@@ -1292,6 +1292,20 @@ function foo(int $i, string $alias) : void {
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));
}',
],
];
}

0 comments on commit 81f513b

Please sign in to comment.
You can’t perform that action at this time.