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

Fix #2685 - always evaluate $a++ in unknown call

This commit is contained in:
Brown 2020-01-24 10:32:28 -05:00
parent 3af48347a9
commit 34d73e7243
2 changed files with 13 additions and 0 deletions

View File

@ -644,6 +644,10 @@ class CallAnalyzer
|| $arg->value instanceof PhpParser\Node\Expr\Array_
|| $arg->value instanceof PhpParser\Node\Expr\BinaryOp
|| $arg->value instanceof PhpParser\Node\Scalar\Encapsed
|| $arg->value instanceof PhpParser\Node\Expr\PostInc
|| $arg->value instanceof PhpParser\Node\Expr\PostDec
|| $arg->value instanceof PhpParser\Node\Expr\PreInc
|| $arg->value instanceof PhpParser\Node\Expr\PreDec
) {
$was_inside_call = $context->inside_call;
$context->inside_call = true;

View File

@ -987,6 +987,15 @@ class CallableTest extends TestCase
}',
'error_message' => 'MixedArgumentTypeCoercion'
],
'undefinedVarInBareCallable' => [
'<?php
$fn = function(int $a): void{};
function a(callable $fn): void{
$fn(++$a);
}
a($fn);',
'error_message' => 'UndefinedVariable',
],
];
}
}